Search in sources :

Example 6 with CompiledExpression

use of io.confluent.ksql.execution.codegen.CompiledExpression 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)

Aggregations

CompiledExpression (io.confluent.ksql.execution.codegen.CompiledExpression)6 CodeGenRunner (io.confluent.ksql.execution.codegen.CodeGenRunner)5 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)5 GenericRow (io.confluent.ksql.GenericRow)4 Expression (io.confluent.ksql.execution.expression.tree.Expression)4 ProcessingLogger (io.confluent.ksql.logging.processing.ProcessingLogger)4 GenericKey (io.confluent.ksql.GenericKey)3 QueryContext (io.confluent.ksql.execution.context.QueryContext)3 RuntimeBuildContext (io.confluent.ksql.execution.runtime.RuntimeBuildContext)3 Formats (io.confluent.ksql.execution.plan.Formats)2 KStreamHolder (io.confluent.ksql.execution.plan.KStreamHolder)2 PhysicalSchema (io.confluent.ksql.schema.ksql.PhysicalSchema)2 List (java.util.List)2 Objects.requireNonNull (java.util.Objects.requireNonNull)2 Function (java.util.function.Function)2 Serde (org.apache.kafka.common.serialization.Serde)2 Grouped (org.apache.kafka.streams.kstream.Grouped)2 ColumnReferenceExp (io.confluent.ksql.execution.expression.tree.ColumnReferenceExp)1 FunctionCall (io.confluent.ksql.execution.expression.tree.FunctionCall)1 KudtfFlatMapper (io.confluent.ksql.execution.function.udtf.KudtfFlatMapper)1