use of io.confluent.ksql.execution.context.QueryContext.Stacker in project ksql by confluentinc.
the class AggregateNode method aggregate.
private SchemaKTable<?> aggregate(final SchemaKGroupedStream grouped, final InternalSchema internalSchema, final Stacker contextStacker) {
final List<FunctionCall> functions = internalSchema.updateFunctionList(functionList);
final Stacker aggregationContext = contextStacker.push(AGGREGATION_OP_NAME);
final List<ColumnName> requiredColumnNames = requiredColumns.stream().map(e -> (UnqualifiedColumnReferenceExp) internalSchema.resolveToInternal(e)).map(UnqualifiedColumnReferenceExp::getColumnName).collect(Collectors.toList());
return grouped.aggregate(requiredColumnNames, functions, windowExpression, valueFormat.getFormatInfo(), aggregationContext);
}
use of io.confluent.ksql.execution.context.QueryContext.Stacker in project ksql by confluentinc.
the class SchemaKSourceFactory method buildTable.
private static SchemaKTable<?> buildTable(final PlanBuildContext buildContext, final DataSource dataSource, final Stacker contextStacker) {
final KeyFormat keyFormat = dataSource.getKsqlTopic().getKeyFormat();
if (keyFormat.isWindowed()) {
throw new IllegalArgumentException("windowed");
}
final SourceStep<KTableHolder<GenericKey>> step;
final int pseudoColumnVersionToUse = determinePseudoColumnVersionToUse(buildContext);
// If the old query has a v1 table step, continue to use it.
// See https://github.com/confluentinc/ksql/pull/7990
boolean useOldExecutionStepVersion = false;
if (buildContext.getPlanInfo().isPresent()) {
final Set<ExecutionStep<?>> sourceSteps = buildContext.getPlanInfo().get().getSources();
useOldExecutionStepVersion = sourceSteps.stream().anyMatch(executionStep -> executionStep instanceof TableSourceV1);
}
if (useOldExecutionStepVersion && pseudoColumnVersionToUse != SystemColumns.LEGACY_PSEUDOCOLUMN_VERSION_NUMBER) {
throw new IllegalStateException("TableSourceV2 was released in conjunction with pseudocolumn" + "version 1. Something has gone very wrong");
}
if (buildContext.getKsqlConfig().getBoolean(KsqlConfig.KSQL_ROWPARTITION_ROWOFFSET_ENABLED) && !useOldExecutionStepVersion) {
step = ExecutionStepFactory.tableSource(contextStacker, dataSource.getSchema(), dataSource.getKafkaTopicName(), Formats.from(dataSource.getKsqlTopic()), dataSource.getTimestampColumn(), InternalFormats.of(keyFormat, Formats.from(dataSource.getKsqlTopic()).getValueFormat()), pseudoColumnVersionToUse);
} else {
step = ExecutionStepFactory.tableSourceV1(contextStacker, dataSource.getSchema(), dataSource.getKafkaTopicName(), Formats.from(dataSource.getKsqlTopic()), dataSource.getTimestampColumn(), pseudoColumnVersionToUse);
}
return schemaKTable(buildContext, resolveSchema(buildContext, step, dataSource), dataSource.getKsqlTopic().getKeyFormat(), step);
}
use of io.confluent.ksql.execution.context.QueryContext.Stacker in project ksql by confluentinc.
the class PlanBuildContextTest method shouldBuildNodeContext.
@Test
public void shouldBuildNodeContext() {
// When:
final Stacker result = runtimeBuildContext.buildNodeContext("some-id");
// Then:
assertThat(result, is(new Stacker().push("some-id")));
}
use of io.confluent.ksql.execution.context.QueryContext.Stacker in project ksql by confluentinc.
the class KsqlMaterializationFactoryTest method shouldUseCorrectLoggerForPredicate.
@Test
public void shouldUseCorrectLoggerForPredicate() {
// When:
factory.create(materialization, info, queryId, new Stacker().push("filter"));
// Then:
verify(predicateInfo).getPredicate(loggerCaptor.capture());
assertThat(loggerCaptor.getValue().apply(new Stacker().getQueryContext()), is(filterProcessingLogger));
}
Aggregations