Search in sources :

Example 11 with QueryContext

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));
}
Also used : QueryContext(io.confluent.ksql.execution.context.QueryContext) Test(org.junit.Test)

Example 12 with QueryContext

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");
}
Also used : QueryContext(io.confluent.ksql.execution.context.QueryContext) Test(org.junit.Test)

Example 13 with QueryContext

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\""));
}
Also used : QueryContext(io.confluent.ksql.execution.context.QueryContext) Test(org.junit.Test)

Example 14 with QueryContext

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);
}
Also used : GenericRow(io.confluent.ksql.GenericRow) PhysicalSchema(io.confluent.ksql.schema.ksql.PhysicalSchema) QueryContext(io.confluent.ksql.execution.context.QueryContext) GenericKey(io.confluent.ksql.GenericKey)

Example 15 with QueryContext

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));
}
Also used : TimestampColumn(io.confluent.ksql.execution.timestamp.TimestampColumn) Column(io.confluent.ksql.schema.ksql.Column) TimestampExtractionPolicy(io.confluent.ksql.execution.streams.timestamp.TimestampExtractionPolicy) QueryContext(io.confluent.ksql.execution.context.QueryContext)

Aggregations

QueryContext (io.confluent.ksql.execution.context.QueryContext)22 GenericRow (io.confluent.ksql.GenericRow)13 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)12 PhysicalSchema (io.confluent.ksql.schema.ksql.PhysicalSchema)10 ProcessingLogger (io.confluent.ksql.logging.processing.ProcessingLogger)8 Formats (io.confluent.ksql.execution.plan.Formats)7 Test (org.junit.Test)7 RuntimeBuildContext (io.confluent.ksql.execution.runtime.RuntimeBuildContext)5 Serde (org.apache.kafka.common.serialization.Serde)5 GenericKey (io.confluent.ksql.GenericKey)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 CodeGenRunner (io.confluent.ksql.execution.codegen.CodeGenRunner)3 CompiledExpression (io.confluent.ksql.execution.codegen.CompiledExpression)3 Expression (io.confluent.ksql.execution.expression.tree.Expression)3 KTableHolder (io.confluent.ksql.execution.plan.KTableHolder)3 KsTransformer (io.confluent.ksql.execution.streams.transform.KsTransformer)3 Objects.requireNonNull (java.util.Objects.requireNonNull)3 Named (org.apache.kafka.streams.kstream.Named)3 KeyValueStore (org.apache.kafka.streams.state.KeyValueStore)3 MaterializationInfo (io.confluent.ksql.execution.materialization.MaterializationInfo)2