Search in sources :

Example 11 with ExecutionStepPropertiesV1

use of io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1 in project ksql by confluentinc.

the class StreamSelectKeyBuilderV1Test method init.

@Before
@SuppressWarnings({ "unchecked", "rawtypes" })
public void init() {
    when(buildContext.getFunctionRegistry()).thenReturn(functionRegistry);
    when(buildContext.getKsqlConfig()).thenReturn(new KsqlConfig(ImmutableMap.of()));
    when(kstream.filter(any())).thenReturn(filteredKStream);
    when(filteredKStream.selectKey(any(KeyValueMapper.class))).thenReturn(rekeyedKstream);
    when(sourceStep.build(any(), eq(planInfo))).thenReturn(new KStreamHolder<>(kstream, SOURCE_SCHEMA, mock(ExecutionKeyFactory.class)));
    planBuilder = new KSPlanBuilder(buildContext, mock(SqlPredicateFactory.class), mock(AggregateParamsFactory.class), mock(StreamsFactories.class));
    selectKey = new StreamSelectKeyV1(new ExecutionStepPropertiesV1(queryContext), sourceStep, KEY);
}
Also used : StreamSelectKeyV1(io.confluent.ksql.execution.plan.StreamSelectKeyV1) KsqlConfig(io.confluent.ksql.util.KsqlConfig) ExecutionStepPropertiesV1(io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1) KeyValueMapper(org.apache.kafka.streams.kstream.KeyValueMapper) Before(org.junit.Before)

Example 12 with ExecutionStepPropertiesV1

use of io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1 in project ksql by confluentinc.

the class TableAggregateBuilderTest method init.

@Before
@SuppressWarnings({ "unchecked", "rawtypes" })
public void init() {
    when(buildContext.buildKeySerde(any(), any(), any())).thenReturn(keySerde);
    when(buildContext.buildValueSerde(any(), any(), any())).thenReturn(valueSerde);
    when(buildContext.getFunctionRegistry()).thenReturn(functionRegistry);
    when(buildContext.getKsqlConfig()).thenReturn(KsqlConfig.empty());
    when(aggregateParamsFactory.createUndoable(any(), any(), any(), any(), any())).thenReturn(aggregateParams);
    when(aggregateParams.getAggregator()).thenReturn((KudafAggregator) aggregator);
    when(aggregateParams.getUndoAggregator()).thenReturn(Optional.of(undoAggregator));
    when(aggregateParams.getInitializer()).thenReturn(initializer);
    when(aggregateParams.getAggregateSchema()).thenReturn(AGGREGATE_SCHEMA);
    when(aggregateParams.getSchema()).thenReturn(AGGREGATE_SCHEMA);
    when(aggregator.getResultMapper()).thenReturn(resultMapper);
    when(materializedFactory.<GenericKey, KeyValueStore<Bytes, byte[]>>create(any(), any(), any())).thenReturn(materialized);
    when(groupedTable.aggregate(any(), any(), any(), any(Materialized.class))).thenReturn(aggregated);
    when(aggregated.transformValues(any(), any(Named.class))).thenReturn((KTable) aggregatedWithResults);
    aggregate = new TableAggregate(new ExecutionStepPropertiesV1(CTX), sourceStep, Formats.of(KEY_FORMAT, VALUE_FORMAT, SerdeFeatures.of(), SerdeFeatures.of()), NON_AGG_COLUMNS, FUNCTIONS);
    when(sourceStep.build(any(), eq(planInfo))).thenReturn(KGroupedTableHolder.of(groupedTable, INPUT_SCHEMA));
    planBuilder = new KSPlanBuilder(buildContext, mock(SqlPredicateFactory.class), aggregateParamsFactory, new StreamsFactories(mock(GroupedFactory.class), mock(JoinedFactory.class), materializedFactory, mock(StreamJoinedFactory.class), mock(ConsumedFactory.class)));
}
Also used : Named(org.apache.kafka.streams.kstream.Named) TableAggregate(io.confluent.ksql.execution.plan.TableAggregate) ExecutionStepPropertiesV1(io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1) KeyValueStore(org.apache.kafka.streams.state.KeyValueStore) GenericKey(io.confluent.ksql.GenericKey) Materialized(org.apache.kafka.streams.kstream.Materialized) Before(org.junit.Before)

Example 13 with ExecutionStepPropertiesV1

use of io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1 in project ksql by confluentinc.

the class TableSuppressBuilderTest method init.

@Before
@SuppressWarnings("unchecked")
public void init() {
    final ExecutionStepPropertiesV1 properties = new ExecutionStepPropertiesV1(queryContext);
    when(physicalSchemaFactory.create(any(), any(), any())).thenReturn(physicalSchema);
    materializedFactory = (a, b) -> materialized;
    when(buildContext.buildValueSerde(any(), any(), any())).thenReturn(valueSerde);
    when(executionKeyFactory.buildKeySerde(any(), any(), any())).thenReturn(keySerde);
    when(buildContext.getKsqlConfig()).thenReturn(ksqlConfig);
    when(ksqlConfig.getLong(any())).thenReturn(maxBytes);
    when(tableHolder.getTable()).thenReturn(sourceKTable);
    when(sourceKTable.transformValues(any(), any(Materialized.class))).thenReturn(preKTable);
    when(preKTable.suppress(any())).thenReturn(suppressedKTable);
    when(tableHolder.withTable(any(), any())).thenReturn(suppressedtable);
    tableSuppress = new TableSuppress<>(properties, sourceStep, refinementInfo, internalFormats);
    builder = new TableSuppressBuilder();
}
Also used : ExecutionStepPropertiesV1(io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1) Materialized(org.apache.kafka.streams.kstream.Materialized) Before(org.junit.Before)

Example 14 with ExecutionStepPropertiesV1

use of io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1 in project ksql by confluentinc.

the class SourceBuilderV1Test method givenUnwindowedSourceStream.

private void givenUnwindowedSourceStream(final int pseudoColumnVersion) {
    when(buildContext.buildKeySerde(any(), any(), any())).thenReturn(keySerde);
    givenConsumed(consumed, keySerde);
    streamSource = new StreamSource(new ExecutionStepPropertiesV1(ctx), TOPIC_NAME, Formats.of(keyFormatInfo, valueFormatInfo, KEY_FEATURES, VALUE_FEATURES), TIMESTAMP_COLUMN, SOURCE_SCHEMA, OptionalInt.of(pseudoColumnVersion));
}
Also used : WindowedStreamSource(io.confluent.ksql.execution.plan.WindowedStreamSource) StreamSource(io.confluent.ksql.execution.plan.StreamSource) ExecutionStepPropertiesV1(io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1)

Example 15 with ExecutionStepPropertiesV1

use of io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1 in project ksql by confluentinc.

the class StreamAggregateBuilderTest method givenHoppingWindowedAggregate.

private void givenHoppingWindowedAggregate() {
    givenTimeWindowedAggregate();
    windowedAggregate = new StreamWindowedAggregate(new ExecutionStepPropertiesV1(CTX), sourceStep, Formats.of(KEY_FORMAT, VALUE_FORMAT, SerdeFeatures.of(), SerdeFeatures.of()), NON_AGG_COLUMNS, FUNCTIONS, new HoppingWindowExpression(Optional.empty(), new WindowTimeClause(WINDOW.getSeconds(), TimeUnit.SECONDS), new WindowTimeClause(HOP.getSeconds(), TimeUnit.SECONDS), Optional.of(retentionClause), Optional.of(gracePeriodClause)));
}
Also used : HoppingWindowExpression(io.confluent.ksql.execution.windows.HoppingWindowExpression) ExecutionStepPropertiesV1(io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1) StreamWindowedAggregate(io.confluent.ksql.execution.plan.StreamWindowedAggregate) WindowTimeClause(io.confluent.ksql.execution.windows.WindowTimeClause)

Aggregations

ExecutionStepPropertiesV1 (io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1)18 Before (org.junit.Before)6 Named (org.apache.kafka.streams.kstream.Named)5 Materialized (org.apache.kafka.streams.kstream.Materialized)4 GenericKey (io.confluent.ksql.GenericKey)3 StreamSource (io.confluent.ksql.execution.plan.StreamSource)3 StreamWindowedAggregate (io.confluent.ksql.execution.plan.StreamWindowedAggregate)3 TableSource (io.confluent.ksql.execution.plan.TableSource)3 WindowedStreamSource (io.confluent.ksql.execution.plan.WindowedStreamSource)3 WindowTimeClause (io.confluent.ksql.execution.windows.WindowTimeClause)3 KeyValueStore (org.apache.kafka.streams.state.KeyValueStore)2 QueryContext (io.confluent.ksql.execution.context.QueryContext)1 PlanInfoExtractor (io.confluent.ksql.execution.plan.PlanInfoExtractor)1 StreamAggregate (io.confluent.ksql.execution.plan.StreamAggregate)1 StreamSelectKeyV1 (io.confluent.ksql.execution.plan.StreamSelectKeyV1)1 TableAggregate (io.confluent.ksql.execution.plan.TableAggregate)1 TableSourceV1 (io.confluent.ksql.execution.plan.TableSourceV1)1 WindowedTableSource (io.confluent.ksql.execution.plan.WindowedTableSource)1 HoppingWindowExpression (io.confluent.ksql.execution.windows.HoppingWindowExpression)1 SessionWindowExpression (io.confluent.ksql.execution.windows.SessionWindowExpression)1