Search in sources :

Example 1 with KSPlanBuilder

use of io.confluent.ksql.execution.streams.KSPlanBuilder in project ksql by confluentinc.

the class AggregateNodeTest method buildQuery.

private SchemaKStream buildQuery(final AggregateNode aggregateNode, final KsqlConfig ksqlConfig) {
    when(buildContext.getKsqlConfig()).thenReturn(ksqlConfig);
    when(buildContext.getFunctionRegistry()).thenReturn(FUNCTION_REGISTRY);
    when(buildContext.buildNodeContext(any())).thenAnswer(inv -> new QueryContext.Stacker().push(inv.getArgument(0).toString()));
    when(runtimeBuildContext.getKsqlConfig()).thenReturn(ksqlConfig);
    when(runtimeBuildContext.getFunctionRegistry()).thenReturn(FUNCTION_REGISTRY);
    when(runtimeBuildContext.getStreamsBuilder()).thenReturn(builder);
    when(runtimeBuildContext.getProcessingLogger(any())).thenReturn(processLogger);
    when(runtimeBuildContext.buildKeySerde(any(), any(), any())).thenReturn(keySerde);
    final SchemaKTable schemaKTable = (SchemaKTable) aggregateNode.buildStream(buildContext);
    schemaKTable.getSourceTableStep().build(new KSPlanBuilder(runtimeBuildContext));
    return schemaKTable;
}
Also used : SchemaKTable(io.confluent.ksql.structured.SchemaKTable) KSPlanBuilder(io.confluent.ksql.execution.streams.KSPlanBuilder)

Example 2 with KSPlanBuilder

use of io.confluent.ksql.execution.streams.KSPlanBuilder in project ksql by confluentinc.

the class DataSourceNodeTest method buildStream.

private SchemaKStream<?> buildStream(final DataSourceNode node) {
    final SchemaKStream<?> stream = node.buildStream(buildContext);
    if (stream instanceof SchemaKTable) {
        final SchemaKTable<?> table = (SchemaKTable<?>) stream;
        table.getSourceTableStep().build(new KSPlanBuilder(executeContext));
    } else {
        stream.getSourceStep().build(new KSPlanBuilder(executeContext));
    }
    return stream;
}
Also used : SchemaKTable(io.confluent.ksql.structured.SchemaKTable) KSPlanBuilder(io.confluent.ksql.execution.streams.KSPlanBuilder)

Example 3 with KSPlanBuilder

use of io.confluent.ksql.execution.streams.KSPlanBuilder in project ksql by confluentinc.

the class SchemaKTableTest method init.

@Before
public void init() {
    UserFunctionLoader.newInstance(ksqlConfig, functionRegistry, ".", new Metrics()).load();
    schemaResolver = new StepSchemaResolver(ksqlConfig, functionRegistry);
    ksqlTable = (KsqlTable) metaStore.getSource(SourceName.of("TEST2"));
    final StreamsBuilder builder = new StreamsBuilder();
    kTable = builder.table(ksqlTable.getKsqlTopic().getKafkaTopicName(), Consumed.with(Serdes.String(), getRowSerde(ksqlTable.getKsqlTopic(), ksqlTable.getSchema())));
    secondKsqlTable = (KsqlTable) metaStore.getSource(SourceName.of("TEST3"));
    secondKTable = builder.table(secondKsqlTable.getKsqlTopic().getKafkaTopicName(), Consumed.with(Serdes.String(), getRowSerde(secondKsqlTable.getKsqlTopic(), secondKsqlTable.getSchema())));
    mockKTable = mock(KTable.class);
    firstSchemaKTable = buildSchemaKTableForJoin(ksqlTable, mockKTable);
    secondSchemaKTable = buildSchemaKTableForJoin(secondKsqlTable, secondKTable);
    when(executeContext.getKsqlConfig()).thenReturn(ksqlConfig);
    when(executeContext.getFunctionRegistry()).thenReturn(functionRegistry);
    when(executeContext.getProcessingLogger(any())).thenReturn(processingLogger);
    planBuilder = new KSPlanBuilder(executeContext, mock(SqlPredicateFactory.class), mock(AggregateParamsFactory.class), new StreamsFactories(groupedFactory, mock(JoinedFactory.class), mock(MaterializedFactory.class), mock(StreamJoinedFactory.class), mock(ConsumedFactory.class)));
}
Also used : StreamsBuilder(org.apache.kafka.streams.StreamsBuilder) KSPlanBuilder(io.confluent.ksql.execution.streams.KSPlanBuilder) Metrics(org.apache.kafka.common.metrics.Metrics) MaterializedFactory(io.confluent.ksql.execution.streams.MaterializedFactory) StreamJoinedFactory(io.confluent.ksql.execution.streams.StreamJoinedFactory) ConsumedFactory(io.confluent.ksql.execution.streams.ConsumedFactory) StreamsFactories(io.confluent.ksql.execution.streams.StreamsFactories) JoinedFactory(io.confluent.ksql.execution.streams.JoinedFactory) StreamJoinedFactory(io.confluent.ksql.execution.streams.StreamJoinedFactory) KTable(org.apache.kafka.streams.kstream.KTable) StepSchemaResolver(io.confluent.ksql.execution.streams.StepSchemaResolver) Before(org.junit.Before)

Example 4 with KSPlanBuilder

use of io.confluent.ksql.execution.streams.KSPlanBuilder in project ksql by confluentinc.

the class JoinNodeTest method buildJoin.

private void buildJoin(final String queryString) {
    buildJoinNode(queryString);
    final SchemaKStream<?> stream = joinNode.buildStream(planBuildContext);
    if (stream instanceof SchemaKTable) {
        final SchemaKTable<?> table = (SchemaKTable<?>) stream;
        table.getSourceTableStep().build(new KSPlanBuilder(executeContext));
    } else {
        stream.getSourceStep().build(new KSPlanBuilder(executeContext));
    }
}
Also used : SchemaKTable(io.confluent.ksql.structured.SchemaKTable) KSPlanBuilder(io.confluent.ksql.execution.streams.KSPlanBuilder)

Example 5 with KSPlanBuilder

use of io.confluent.ksql.execution.streams.KSPlanBuilder in project ksql by confluentinc.

the class KsqlBareOutputNodeTest method before.

@Before
public void before() {
    builder = new StreamsBuilder();
    when(planBuildContext.getKsqlConfig()).thenReturn(new KsqlConfig(Collections.emptyMap()));
    when(planBuildContext.getFunctionRegistry()).thenReturn(functionRegistry);
    when(planBuildContext.buildNodeContext(any())).thenAnswer(inv -> new QueryContext.Stacker().push(inv.getArgument(0).toString()));
    when(executeContext.getKsqlConfig()).thenReturn(new KsqlConfig(Collections.emptyMap()));
    when(executeContext.getFunctionRegistry()).thenReturn(functionRegistry);
    when(executeContext.buildKeySerde(any(), any(), any())).thenReturn(keySerde);
    when(executeContext.getStreamsBuilder()).thenReturn(builder);
    when(executeContext.getProcessingLogger(any())).thenReturn(processingLogger);
    final KsqlBareOutputNode planNode = (KsqlBareOutputNode) AnalysisTestUtil.buildLogicalPlan(ksqlConfig, SIMPLE_SELECT_WITH_FILTER, metaStore);
    stream = planNode.buildStream(planBuildContext);
    stream.getSourceStep().build(new KSPlanBuilder(executeContext));
}
Also used : StreamsBuilder(org.apache.kafka.streams.StreamsBuilder) KSPlanBuilder(io.confluent.ksql.execution.streams.KSPlanBuilder) KsqlConfig(io.confluent.ksql.util.KsqlConfig) Before(org.junit.Before)

Aggregations

KSPlanBuilder (io.confluent.ksql.execution.streams.KSPlanBuilder)5 SchemaKTable (io.confluent.ksql.structured.SchemaKTable)3 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)2 Before (org.junit.Before)2 ConsumedFactory (io.confluent.ksql.execution.streams.ConsumedFactory)1 JoinedFactory (io.confluent.ksql.execution.streams.JoinedFactory)1 MaterializedFactory (io.confluent.ksql.execution.streams.MaterializedFactory)1 StepSchemaResolver (io.confluent.ksql.execution.streams.StepSchemaResolver)1 StreamJoinedFactory (io.confluent.ksql.execution.streams.StreamJoinedFactory)1 StreamsFactories (io.confluent.ksql.execution.streams.StreamsFactories)1 KsqlConfig (io.confluent.ksql.util.KsqlConfig)1 Metrics (org.apache.kafka.common.metrics.Metrics)1 KTable (org.apache.kafka.streams.kstream.KTable)1