Search in sources :

Example 16 with ProcessingLogger

use of io.confluent.ksql.logging.processing.ProcessingLogger in project ksql by confluentinc.

the class PullPhysicalPlanBuilder method translateFilterNode.

private SelectOperator translateFilterNode(final QueryFilterNode logicalNode) {
    lookupConstraints = logicalNode.getLookupConstraints();
    final ProcessingLogger logger = processingLogContext.getLoggerFactory().getLogger(QueryLoggerUtil.queryLoggerName(QueryType.PULL_QUERY, contextStacker.push("SELECT").getQueryContext()));
    return new SelectOperator(logicalNode, logger);
}
Also used : ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) SelectOperator(io.confluent.ksql.physical.common.operators.SelectOperator)

Example 17 with ProcessingLogger

use of io.confluent.ksql.logging.processing.ProcessingLogger in project ksql by confluentinc.

the class StaticTopicSerdeTest method shouldTrySourceTopicAndCallCallbackOnDeserializationFailureWithLoggingDeserializer.

@Test
public void shouldTrySourceTopicAndCallCallbackOnDeserializationFailureWithLoggingDeserializer() {
    // Given:
    when(delegateD.deserialize(Mockito.eq(STATIC_TOPIC), Mockito.any())).thenThrow(new RuntimeException());
    final ProcessingLogger logger = mock(ProcessingLogger.class);
    final LoggingDeserializer<Object> loggingDelegate = new LoggingDeserializer<>(delegateD, logger);
    final Serde<Object> delegate = new WrapperSerde<>(delegateS, loggingDelegate);
    staticSerde = StaticTopicSerde.wrap(STATIC_TOPIC, delegate, callback);
    // When:
    final Object deserialized = staticSerde.deserializer().deserialize(SOURCE_TOPIC, SOME_BYTES);
    // Then:
    verifyNoMoreInteractions(logger);
    verify(callback).onDeserializationFailure(SOURCE_TOPIC, STATIC_TOPIC, SOME_BYTES);
    assertThat(deserialized, is(SOME_OBJECT));
}
Also used : ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) WrapperSerde(org.apache.kafka.common.serialization.Serdes.WrapperSerde) LoggingDeserializer(io.confluent.ksql.logging.processing.LoggingDeserializer) Test(org.junit.Test)

Example 18 with ProcessingLogger

use of io.confluent.ksql.logging.processing.ProcessingLogger in project ksql by confluentinc.

the class StreamSelectKeyBuilder method build.

@VisibleForTesting
static <K> KStreamHolder<K> build(final KStreamHolder<K> stream, final StreamSelectKey<K> selectKey, final RuntimeBuildContext buildContext, final PartitionByParamsBuilder paramsBuilder) {
    final LogicalSchema sourceSchema = stream.getSchema();
    final QueryContext queryContext = selectKey.getProperties().getQueryContext();
    final ProcessingLogger logger = buildContext.getProcessingLogger(queryContext);
    final PartitionByParams<K> params = paramsBuilder.build(sourceSchema, stream.getExecutionKeyFactory(), selectKey.getKeyExpressions(), buildContext.getKsqlConfig(), buildContext.getFunctionRegistry(), logger);
    final Mapper<K> mapper = params.getMapper();
    final KStream<K, GenericRow> kStream = stream.getStream();
    final KStream<K, GenericRow> reKeyed = kStream.map(mapper, Named.as(queryContext.formatContext() + "-SelectKey"));
    return new KStreamHolder<>(reKeyed, params.getSchema(), stream.getExecutionKeyFactory().withQueryBuilder(buildContext));
}
Also used : GenericRow(io.confluent.ksql.GenericRow) ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) KStreamHolder(io.confluent.ksql.execution.plan.KStreamHolder) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) QueryContext(io.confluent.ksql.execution.context.QueryContext) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 19 with ProcessingLogger

use of io.confluent.ksql.logging.processing.ProcessingLogger in project ksql by confluentinc.

the class StreamGroupByBuilderBase method build.

public <K> KGroupedStreamHolder build(final KStreamHolder<K> stream, final QueryContext queryContext, final Formats formats, final List<Expression> groupByExpressions) {
    final LogicalSchema sourceSchema = stream.getSchema();
    final List<CompiledExpression> groupBy = CodeGenRunner.compileExpressions(groupByExpressions.stream(), "Group By", sourceSchema, buildContext.getKsqlConfig(), buildContext.getFunctionRegistry());
    final ProcessingLogger logger = buildContext.getProcessingLogger(queryContext);
    final GroupByParams params = paramsFactory.build(sourceSchema, groupBy, logger);
    final Grouped<GenericKey, GenericRow> grouped = buildGrouped(formats, params.getSchema(), queryContext, buildContext, groupedFactory);
    final KGroupedStream<GenericKey, GenericRow> groupedStream = stream.getStream().filter((k, v) -> v != null).groupBy((k, v) -> params.getMapper().apply(v), grouped);
    return KGroupedStreamHolder.of(groupedStream, params.getSchema());
}
Also used : GenericRow(io.confluent.ksql.GenericRow) PhysicalSchema(io.confluent.ksql.schema.ksql.PhysicalSchema) RuntimeBuildContext(io.confluent.ksql.execution.runtime.RuntimeBuildContext) KGroupedStream(org.apache.kafka.streams.kstream.KGroupedStream) Expression(io.confluent.ksql.execution.expression.tree.Expression) QueryContext(io.confluent.ksql.execution.context.QueryContext) CompiledExpression(io.confluent.ksql.execution.codegen.CompiledExpression) Formats(io.confluent.ksql.execution.plan.Formats) StreamGroupByKey(io.confluent.ksql.execution.plan.StreamGroupByKey) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) CodeGenRunner(io.confluent.ksql.execution.codegen.CodeGenRunner) Grouped(org.apache.kafka.streams.kstream.Grouped) KGroupedStreamHolder(io.confluent.ksql.execution.plan.KGroupedStreamHolder) KStreamHolder(io.confluent.ksql.execution.plan.KStreamHolder) List(java.util.List) GenericRow(io.confluent.ksql.GenericRow) Serde(org.apache.kafka.common.serialization.Serde) Objects.requireNonNull(java.util.Objects.requireNonNull) ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) GenericKey(io.confluent.ksql.GenericKey) ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) GenericKey(io.confluent.ksql.GenericKey) CompiledExpression(io.confluent.ksql.execution.codegen.CompiledExpression)

Example 20 with ProcessingLogger

use of io.confluent.ksql.logging.processing.ProcessingLogger in project ksql by confluentinc.

the class StreamFilterBuilder method build.

static <K> KStreamHolder<K> build(final KStreamHolder<K> stream, final StreamFilter<K> step, final RuntimeBuildContext buildContext, final SqlPredicateFactory predicateFactory) {
    final SqlPredicate predicate = predicateFactory.create(step.getFilterExpression(), stream.getSchema(), buildContext.getKsqlConfig(), buildContext.getFunctionRegistry());
    final ProcessingLogger processingLogger = buildContext.getProcessingLogger(step.getProperties().getQueryContext());
    final KStream<K, GenericRow> filtered = stream.getStream().flatTransformValues(() -> toFlatMapTransformer(predicate.getTransformer(processingLogger)), Named.as(StreamsUtil.buildOpName(step.getProperties().getQueryContext())));
    return stream.withStream(filtered, stream.getSchema());
}
Also used : GenericRow(io.confluent.ksql.GenericRow) ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) SqlPredicate(io.confluent.ksql.execution.transform.sqlpredicate.SqlPredicate)

Aggregations

ProcessingLogger (io.confluent.ksql.logging.processing.ProcessingLogger)21 GenericRow (io.confluent.ksql.GenericRow)11 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)10 QueryContext (io.confluent.ksql.execution.context.QueryContext)7 CodeGenRunner (io.confluent.ksql.execution.codegen.CodeGenRunner)6 Test (org.junit.Test)6 CompiledExpression (io.confluent.ksql.execution.codegen.CompiledExpression)5 Expression (io.confluent.ksql.execution.expression.tree.Expression)5 RuntimeBuildContext (io.confluent.ksql.execution.runtime.RuntimeBuildContext)5 GenericKey (io.confluent.ksql.GenericKey)4 Stacker (io.confluent.ksql.execution.context.QueryContext.Stacker)4 Formats (io.confluent.ksql.execution.plan.Formats)4 PhysicalSchema (io.confluent.ksql.schema.ksql.PhysicalSchema)4 KStreamHolder (io.confluent.ksql.execution.plan.KStreamHolder)3 KTableHolder (io.confluent.ksql.execution.plan.KTableHolder)3 KsTransformer (io.confluent.ksql.execution.streams.transform.KsTransformer)3 LoggingDeserializer (io.confluent.ksql.logging.processing.LoggingDeserializer)3 List (java.util.List)3 Serde (org.apache.kafka.common.serialization.Serde)3 WrapperSerde (org.apache.kafka.common.serialization.Serdes.WrapperSerde)3