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())));
}
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());
}
Aggregations