Search in sources :

Example 1 with SqlPredicate

use of io.confluent.ksql.execution.transform.sqlpredicate.SqlPredicate in project ksql by confluentinc.

the class TableFilterBuilder method build.

static <K> KTableHolder<K> build(final KTableHolder<K> table, final TableFilter<K> step, final RuntimeBuildContext buildContext, final SqlPredicateFactory sqlPredicateFactory) {
    final SqlPredicate predicate = sqlPredicateFactory.create(step.getFilterExpression(), table.getSchema(), buildContext.getKsqlConfig(), buildContext.getFunctionRegistry());
    final ProcessingLogger processingLogger = buildContext.getProcessingLogger(step.getProperties().getQueryContext());
    final Stacker stacker = Stacker.of(step.getProperties().getQueryContext());
    final KTable<K, GenericRow> filtered = table.getTable().transformValues(() -> new KsTransformer<>(predicate.getTransformer(processingLogger)), Named.as(StreamsUtil.buildOpName(stacker.push(PRE_PROCESS_OP).getQueryContext()))).filter((k, v) -> v.isPresent(), Named.as(StreamsUtil.buildOpName(stacker.push(FILTER_OP).getQueryContext()))).mapValues(Optional::get, Named.as(StreamsUtil.buildOpName(stacker.push(POST_PROCESS_OP).getQueryContext())));
    return table.withTable(filtered, table.getSchema()).withMaterialization(table.getMaterializationBuilder().map(b -> b.filter(predicate::getTransformer, step.getProperties().getQueryContext())));
}
Also used : GenericRow(io.confluent.ksql.GenericRow) SqlPredicate(io.confluent.ksql.execution.transform.sqlpredicate.SqlPredicate) KTableHolder(io.confluent.ksql.execution.plan.KTableHolder) TableFilter(io.confluent.ksql.execution.plan.TableFilter) KTable(org.apache.kafka.streams.kstream.KTable) RuntimeBuildContext(io.confluent.ksql.execution.runtime.RuntimeBuildContext) KsTransformer(io.confluent.ksql.execution.streams.transform.KsTransformer) GenericRow(io.confluent.ksql.GenericRow) Stacker(io.confluent.ksql.execution.context.QueryContext.Stacker) Named(org.apache.kafka.streams.kstream.Named) ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) Optional(java.util.Optional) ProcessingLogger(io.confluent.ksql.logging.processing.ProcessingLogger) Optional(java.util.Optional) SqlPredicate(io.confluent.ksql.execution.transform.sqlpredicate.SqlPredicate) Stacker(io.confluent.ksql.execution.context.QueryContext.Stacker)

Example 2 with SqlPredicate

use of io.confluent.ksql.execution.transform.sqlpredicate.SqlPredicate 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

GenericRow (io.confluent.ksql.GenericRow)2 SqlPredicate (io.confluent.ksql.execution.transform.sqlpredicate.SqlPredicate)2 ProcessingLogger (io.confluent.ksql.logging.processing.ProcessingLogger)2 Stacker (io.confluent.ksql.execution.context.QueryContext.Stacker)1 KTableHolder (io.confluent.ksql.execution.plan.KTableHolder)1 TableFilter (io.confluent.ksql.execution.plan.TableFilter)1 RuntimeBuildContext (io.confluent.ksql.execution.runtime.RuntimeBuildContext)1 KsTransformer (io.confluent.ksql.execution.streams.transform.KsTransformer)1 Optional (java.util.Optional)1 KTable (org.apache.kafka.streams.kstream.KTable)1 Named (org.apache.kafka.streams.kstream.Named)1