public static Page createSequencePageWithDictionaryBlocks(List<? extends Type> types, int length, int... initialValues) { Block[] blocks = new Block[initialValues.length]; for (int i = 0; i < blocks.length; i++) { Type type = types.get(i); int initialValue = initialValues[i]; if (type.equals(VARCHAR)) { blocks[i] = BlockAssertions.createStringDictionaryBlock(initialValue, initialValue + length); } else if (type.equals(BIGINT)) { blocks[i] = BlockAssertions.createLongDictionaryBlock(initialValue, initialValue + length); } else { throw new IllegalStateException("Unsupported type " + type); } } return new Page(blocks); } }
@Test public void testNonDeterministicProject() { 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(constant(10L, BIGINT))); InputReferenceExpression col0 = field(0, BIGINT); CallExpression lessThanRandomExpression = new CallExpression(lessThan, BOOLEAN, ImmutableList.of(col0, random)); PageProcessor processor = compiler.compilePageProcessor(Optional.empty(), ImmutableList.of(lessThanRandomExpression), MAX_BATCH_SIZE).get(); assertFalse(new DeterminismEvaluator(metadataManager.getFunctionRegistry()).isDeterministic(lessThanRandomExpression)); Page page = new Page(createLongDictionaryBlock(1, 100)); Page outputPage = getOnlyElement( processor.process( null, new DriverYieldSignal(), newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName()), page)) .orElseThrow(() -> new AssertionError("page is not present")); assertFalse(outputPage.getBlock(0) instanceof DictionaryBlock); }
public static Page createSequencePageWithDictionaryBlocks(List<? extends Type> types, int length, int... initialValues) { Block[] blocks = new Block[initialValues.length]; for (int i = 0; i < blocks.length; i++) { Type type = types.get(i); int initialValue = initialValues[i]; if (type.equals(VARCHAR)) { blocks[i] = BlockAssertions.createStringDictionaryBlock(initialValue, initialValue + length); } else if (type.equals(BIGINT)) { blocks[i] = BlockAssertions.createLongDictionaryBlock(initialValue, initialValue + length); } else { throw new IllegalStateException("Unsupported type " + type); } } return new Page(blocks); } }
@Test public void testNonDeterministicProject() throws Exception { Signature lessThan = internalOperator(LESS_THAN, BOOLEAN, ImmutableList.of(BIGINT, BIGINT)); CallExpression random = new CallExpression(new Signature("random", SCALAR, "bigint", "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); }