Search in sources :

Example 11 with WindowTimeClause

use of io.confluent.ksql.execution.windows.WindowTimeClause in project ksql by confluentinc.

the class WithinExpressionTest method shouldDisplayCorrectStringWithGracePeriod.

@Test
public void shouldDisplayCorrectStringWithGracePeriod() {
    final WindowTimeClause gracePeriod = new WindowTimeClause(5, TimeUnit.SECONDS);
    final WithinExpression expression = new WithinExpression(20, TimeUnit.SECONDS, gracePeriod);
    assertEquals(" WITHIN 20 SECONDS GRACE PERIOD 5 SECONDS", expression.toString());
    assertEquals(JoinWindows.of(Duration.ofSeconds(20)).grace(Duration.ofSeconds(5)), expression.joinWindow());
}
Also used : WindowTimeClause(io.confluent.ksql.execution.windows.WindowTimeClause) Test(org.junit.Test)

Example 12 with WindowTimeClause

use of io.confluent.ksql.execution.windows.WindowTimeClause in project ksql by confluentinc.

the class StepSchemaResolverTest method shouldResolveSchemaForStreamWindowedAggregate.

@Test
public void shouldResolveSchemaForStreamWindowedAggregate() {
    // Given:
    givenAggregateFunction("COUNT", SqlTypes.BIGINT);
    final StreamWindowedAggregate step = new StreamWindowedAggregate(PROPERTIES, groupedStreamSource, formats, ImmutableList.of(ColumnName.of("ORANGE")), ImmutableList.of(functionCall("COUNT", "APPLE")), new TumblingWindowExpression(new WindowTimeClause(10, TimeUnit.SECONDS)));
    // 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).valueColumn(SystemColumns.WINDOWSTART_NAME, SystemColumns.WINDOWBOUND_TYPE).valueColumn(SystemColumns.WINDOWEND_NAME, SystemColumns.WINDOWBOUND_TYPE).build()));
}
Also used : StreamWindowedAggregate(io.confluent.ksql.execution.plan.StreamWindowedAggregate) WindowTimeClause(io.confluent.ksql.execution.windows.WindowTimeClause) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) TumblingWindowExpression(io.confluent.ksql.execution.windows.TumblingWindowExpression) Test(org.junit.Test)

Example 13 with WindowTimeClause

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

Example 14 with WindowTimeClause

use of io.confluent.ksql.execution.windows.WindowTimeClause in project ksql by confluentinc.

the class StreamAggregateBuilderTest method givenTumblingWindowedAggregate.

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

Aggregations

WindowTimeClause (io.confluent.ksql.execution.windows.WindowTimeClause)14 Test (org.junit.Test)10 TumblingWindowExpression (io.confluent.ksql.execution.windows.TumblingWindowExpression)7 StreamWindowedAggregate (io.confluent.ksql.execution.plan.StreamWindowedAggregate)4 ExecutionStepPropertiesV1 (io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1)3 KsqlWindowExpression (io.confluent.ksql.execution.windows.KsqlWindowExpression)3 WithinExpression (io.confluent.ksql.parser.tree.WithinExpression)3 HoppingWindowExpression (io.confluent.ksql.execution.windows.HoppingWindowExpression)2 SessionWindowExpression (io.confluent.ksql.execution.windows.SessionWindowExpression)2 PreparedStatement (io.confluent.ksql.parser.KsqlParser.PreparedStatement)2 CreateStreamAsSelect (io.confluent.ksql.parser.tree.CreateStreamAsSelect)2 Join (io.confluent.ksql.parser.tree.Join)2 JoinedSource (io.confluent.ksql.parser.tree.JoinedSource)2 Query (io.confluent.ksql.parser.tree.Query)2 Statement (io.confluent.ksql.parser.tree.Statement)2 TerminateQuery (io.confluent.ksql.parser.tree.TerminateQuery)2 WindowExpression (io.confluent.ksql.parser.tree.WindowExpression)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 GenericKey (io.confluent.ksql.GenericKey)1 JoinType (io.confluent.ksql.execution.plan.JoinType)1