Search in sources :

Example 1 with DeterminismEvaluator

use of com.facebook.presto.sql.relational.DeterminismEvaluator in project presto by prestodb.

the class TestPageProcessorCompiler method testNonDeterministicProject.

@Test
public void testNonDeterministicProject() throws Exception {
    Signature lessThan = internalOperator(LESS_THAN, BOOLEAN, ImmutableList.of(BIGINT, BIGINT));
    CallExpression random = new CallExpression(new Signature("random", SCALAR, parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.BIGINT)), BIGINT, singletonList(new ConstantExpression(10L, BIGINT)));
    InputReferenceExpression col0 = new InputReferenceExpression(0, BIGINT);
    CallExpression lessThanRandomExpression = new CallExpression(lessThan, BOOLEAN, ImmutableList.of(col0, random));
    PageProcessor processor = new ExpressionCompiler(createTestMetadataManager()).compilePageProcessor(new ConstantExpression(TRUE, BOOLEAN), ImmutableList.of(lessThanRandomExpression)).get();
    assertFalse(new DeterminismEvaluator(METADATA_MANAGER.getFunctionRegistry()).isDeterministic(lessThanRandomExpression));
    Page page = new Page(createLongDictionaryBlock(1, 100));
    Page outputPage = processor.processColumnarDictionary(null, page, ImmutableList.of(BOOLEAN));
    assertFalse(outputPage.getBlock(0) instanceof DictionaryBlock);
}
Also used : InputReferenceExpression(com.facebook.presto.sql.relational.InputReferenceExpression) PageProcessor(com.facebook.presto.operator.PageProcessor) DeterminismEvaluator(com.facebook.presto.sql.relational.DeterminismEvaluator) Signature(com.facebook.presto.metadata.Signature) TypeSignature.parseTypeSignature(com.facebook.presto.spi.type.TypeSignature.parseTypeSignature) ConstantExpression(com.facebook.presto.sql.relational.ConstantExpression) DictionaryBlock(com.facebook.presto.spi.block.DictionaryBlock) BlockAssertions.createLongDictionaryBlock(com.facebook.presto.block.BlockAssertions.createLongDictionaryBlock) ExpressionCompiler(com.facebook.presto.sql.gen.ExpressionCompiler) Page(com.facebook.presto.spi.Page) CallExpression(com.facebook.presto.sql.relational.CallExpression) Test(org.testng.annotations.Test)

Aggregations

BlockAssertions.createLongDictionaryBlock (com.facebook.presto.block.BlockAssertions.createLongDictionaryBlock)1 Signature (com.facebook.presto.metadata.Signature)1 PageProcessor (com.facebook.presto.operator.PageProcessor)1 Page (com.facebook.presto.spi.Page)1 DictionaryBlock (com.facebook.presto.spi.block.DictionaryBlock)1 TypeSignature.parseTypeSignature (com.facebook.presto.spi.type.TypeSignature.parseTypeSignature)1 ExpressionCompiler (com.facebook.presto.sql.gen.ExpressionCompiler)1 CallExpression (com.facebook.presto.sql.relational.CallExpression)1 ConstantExpression (com.facebook.presto.sql.relational.ConstantExpression)1 DeterminismEvaluator (com.facebook.presto.sql.relational.DeterminismEvaluator)1 InputReferenceExpression (com.facebook.presto.sql.relational.InputReferenceExpression)1 Test (org.testng.annotations.Test)1