Search in sources :

Example 1 with StreamAggregate

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

the class StepSchemaResolverTest method shouldResolveSchemaForStreamAggregate.

@Test
public void shouldResolveSchemaForStreamAggregate() {
    // Given:
    givenAggregateFunction("SUM", SqlTypes.BIGINT);
    final StreamAggregate step = new StreamAggregate(PROPERTIES, groupedStreamSource, formats, ImmutableList.of(ColumnName.of("ORANGE")), ImmutableList.of(functionCall("SUM", "APPLE")));
    // When:
    final LogicalSchema result = resolver.resolve(step, SCHEMA);
    // Then:
    assertThat(result, is(LogicalSchema.builder().keyColumn(ColumnName.of("K0"), SqlTypes.INTEGER).valueColumn(ColumnName.of("ORANGE"), SqlTypes.INTEGER).valueColumn(ColumnNames.aggregateColumn(0), SqlTypes.BIGINT).build()));
}
Also used : LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) StreamAggregate(io.confluent.ksql.execution.plan.StreamAggregate) Test(org.junit.Test)

Example 2 with StreamAggregate

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

the class StreamAggregateBuilderTest method givenUnwindowedAggregate.

@SuppressWarnings({ "unchecked", "rawtypes" })
private void givenUnwindowedAggregate() {
    when(materializedFactory.<GenericKey, KeyValueStore<Bytes, byte[]>>create(any(), any(), any())).thenReturn(materialized);
    when(groupedStream.aggregate(any(), any(), any(Materialized.class))).thenReturn(aggregated);
    when(aggregated.transformValues(any(), any(Named.class))).thenReturn((KTable) aggregatedWithResults);
    aggregate = new StreamAggregate(new ExecutionStepPropertiesV1(CTX), sourceStep, Formats.of(KEY_FORMAT, VALUE_FORMAT, SerdeFeatures.of(), SerdeFeatures.of()), NON_AGG_COLUMNS, FUNCTIONS);
}
Also used : Named(org.apache.kafka.streams.kstream.Named) 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) StreamAggregate(io.confluent.ksql.execution.plan.StreamAggregate)

Aggregations

StreamAggregate (io.confluent.ksql.execution.plan.StreamAggregate)2 GenericKey (io.confluent.ksql.GenericKey)1 ExecutionStepPropertiesV1 (io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1)1 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)1 Materialized (org.apache.kafka.streams.kstream.Materialized)1 Named (org.apache.kafka.streams.kstream.Named)1 KeyValueStore (org.apache.kafka.streams.state.KeyValueStore)1 Test (org.junit.Test)1