use of io.confluent.ksql.execution.context.QueryContext in project ksql by confluentinc.
the class QueryContextTest method shouldDeserializeCorrectly.
@Test
public void shouldDeserializeCorrectly() throws IOException {
// When:
final QueryContext deserialized = MAPPER.readValue("\"node/child\"", QueryContext.class);
// Then:
final QueryContext expected = contextStacker.push("child").getQueryContext();
assertThat(deserialized, is(expected));
}
use of io.confluent.ksql.execution.context.QueryContext in project ksql by confluentinc.
the class QueryContextTest method shouldGenerateNewContextOnPush.
@Test
public void shouldGenerateNewContextOnPush() {
// When:
final QueryContext.Stacker childContextStacker = contextStacker.push("child");
final QueryContext childContext = childContextStacker.getQueryContext();
final QueryContext grandchildContext = childContextStacker.push("grandchild").getQueryContext();
// Then:
assertThat(ImmutableSet.of(queryContext, childContext, grandchildContext), hasSize(3));
assertQueryContext(queryContext, "node");
assertQueryContext(childContext, "node", "child");
assertQueryContext(grandchildContext, "node", "child", "grandchild");
}
use of io.confluent.ksql.execution.context.QueryContext in project ksql by confluentinc.
the class QueryContextTest method shouldSerializeCorrectly.
@Test
public void shouldSerializeCorrectly() throws IOException {
// Given:
final QueryContext context = contextStacker.push("child").getQueryContext();
// When:
final String serialized = MAPPER.writeValueAsString(context);
// Then:
assertThat(serialized, is("\"node/child\""));
}
use of io.confluent.ksql.execution.context.QueryContext in project ksql by confluentinc.
the class SourceBuilder method buildTableMaterialized.
@Override
Materialized<GenericKey, GenericRow, KeyValueStore<Bytes, byte[]>> buildTableMaterialized(final SourceStep<KTableHolder<GenericKey>> source, final RuntimeBuildContext buildContext, final MaterializedFactory materializedFactory, final Serde<GenericKey> sourceKeySerde, final Serde<GenericRow> sourceValueSerde, final String stateStoreName) {
final PhysicalSchema physicalSchema = getPhysicalSchemaWithPseudoColumnsToMaterialize(source);
final QueryContext queryContext = addMaterializedContext(source);
final Serde<GenericRow> valueSerdeToMaterialize = getValueSerde(buildContext, source, physicalSchema, queryContext);
final Serde<GenericKey> keySerdeToMaterialize = getKeySerde(source, physicalSchema, buildContext, queryContext);
return materializedFactory.create(keySerdeToMaterialize, valueSerdeToMaterialize, stateStoreName);
}
use of io.confluent.ksql.execution.context.QueryContext in project ksql by confluentinc.
the class SourceBuilderUtils method timestampExtractor.
static TimestampExtractor timestampExtractor(final KsqlConfig ksqlConfig, final LogicalSchema sourceSchema, final Optional<TimestampColumn> timestampColumn, final SourceStep<?> streamSource, final RuntimeBuildContext buildContext) {
final TimestampExtractionPolicy timestampPolicy = TimestampExtractionPolicyFactory.create(ksqlConfig, sourceSchema, timestampColumn);
final Optional<Column> tsColumn = timestampColumn.map(TimestampColumn::getColumn).map(c -> sourceSchema.findColumn(c).orElseThrow(IllegalStateException::new));
final QueryContext queryContext = streamSource.getProperties().getQueryContext();
return timestampPolicy.create(tsColumn, ksqlConfig.getBoolean(KsqlConfig.KSQL_TIMESTAMP_THROW_ON_INVALID), buildContext.getProcessingLogger(queryContext));
}
Aggregations