use of io.confluent.ksql.execution.streams.materialization.PullProcessingContext in project ksql by confluentinc.
the class ProjectOperatorTest method shouldProjectOnlyValueNonWindowed.
@Test
public void shouldProjectOnlyValueNonWindowed() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().valueColumn(ColumnName.of("v1"), SqlTypes.STRING).build();
when(logicalNode.getAddAdditionalColumnsToIntermediateSchema()).thenReturn(false);
when(logicalNode.getSchema()).thenReturn(schema);
when(logicalNode.getCompiledSelectExpressions()).thenReturn(Collections.emptyList());
final ProjectOperator projectOperator = new ProjectOperator(logger, logicalNode, selectValueMapperFactorySupplier);
projectOperator.addChild(child);
final QueryRowImpl row = QueryRowImpl.of(INTERMEDIATE_SCHEMA_WITH_PSEUDO, A_KEY, Optional.empty(), GenericRow.genericRow("a", "b", A_ROWTIME, "k"), A_ROWTIME);
when(child.next()).thenReturn(row);
when(selectValueMapperFactorySupplier.create(any(), any())).thenReturn(selectValueMapper);
when(selectValueMapper.getTransformer(logger)).thenReturn(transformer);
when(transformer.transform(A_KEY, row.value(), new PullProcessingContext(12335L))).thenReturn(GenericRow.genericRow("b"));
projectOperator.open();
// When:
QueryRow result = (QueryRow) projectOperator.next();
// Then:
assertThat(result.value().values(), is(ImmutableList.of("b")));
}
use of io.confluent.ksql.execution.streams.materialization.PullProcessingContext in project ksql by confluentinc.
the class SelectOperatorTest method shouldSelectKeyWindowed.
@Test
public void shouldSelectKeyWindowed() {
// Given:
when(logicalNode.getAddAdditionalColumnsToIntermediateSchema()).thenReturn(true);
when(logicalNode.getIntermediateSchema()).thenReturn(WINDOWED_INTERMEDIATE_SCHEMA_WITH_PSEUDO);
when(predicateFactory.create(any(), any())).thenReturn(sqlPredicate);
final SelectOperator selectOperator = new SelectOperator(logicalNode, logger, predicateFactory);
selectOperator.addChild(child);
final QueryRowImpl windowedRow = QueryRowImpl.of(WINDOWED_OUTPUT_SCHEMA, A_KEY, Optional.of(A_WINDOW), GenericRow.genericRow("a", "b"), A_ROWTIME);
when(child.next()).thenReturn(windowedRow);
when(sqlPredicate.getTransformer(logger)).thenReturn(transformer);
final QueryRowImpl intermediateWindowedRow = QueryRowImpl.of(WINDOWED_INTERMEDIATE_SCHEMA_WITH_PSEUDO, A_KEY, Optional.of(A_WINDOW), GenericRow.genericRow("a", "b", A_ROWTIME, "k", A_WINDOW.start().toEpochMilli(), A_WINDOW.end().toEpochMilli()), A_ROWTIME);
when(transformer.transform(A_KEY, intermediateWindowedRow.value(), new PullProcessingContext(12335L))).thenReturn(Optional.of(GenericRow.genericRow("a", "b", A_ROWTIME, "k", A_WINDOW.start().toEpochMilli(), A_WINDOW.end().toEpochMilli())));
selectOperator.open();
// When:
Object result = selectOperator.next();
// Then:
assertThat(result, is(intermediateWindowedRow));
}
Aggregations