Search in sources :

Example 26 with LogicalSchema

use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.

the class StepSchemaResolverTest method shouldResolveSchemaForStreamFilter.

@Test
public void shouldResolveSchemaForStreamFilter() {
    // Given:
    final StreamFilter<?> step = new StreamFilter<>(PROPERTIES, streamSource, mock(Expression.class));
    // When:
    final LogicalSchema result = resolver.resolve(step, SCHEMA);
    // Then:
    assertThat(result, is(SCHEMA));
}
Also used : ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) TumblingWindowExpression(io.confluent.ksql.execution.windows.TumblingWindowExpression) SelectExpression(io.confluent.ksql.execution.plan.SelectExpression) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) StreamFilter(io.confluent.ksql.execution.plan.StreamFilter) Test(org.junit.Test)

Example 27 with LogicalSchema

use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.

the class StepSchemaResolverTest method shouldResolveSchemaForStreamWindowedSource.

@Test
public void shouldResolveSchemaForStreamWindowedSource() {
    final WindowedStreamSource step = new WindowedStreamSource(PROPERTIES, "foo", formats, WindowInfo.of(WindowType.TUMBLING, Optional.of(Duration.ofMillis(123))), Optional.empty(), SCHEMA, OptionalInt.of(SystemColumns.CURRENT_PSEUDOCOLUMN_VERSION_NUMBER));
    // When:
    final LogicalSchema result = resolver.resolve(step, SCHEMA);
    // Then:
    assertThat(result, is(SCHEMA.withPseudoAndKeyColsInValue(true)));
}
Also used : LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) WindowedStreamSource(io.confluent.ksql.execution.plan.WindowedStreamSource) Test(org.junit.Test)

Example 28 with LogicalSchema

use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.

the class AggregateParamsFactoryTest method shouldReturnCorrectWindowedSchema.

@Test
public void shouldReturnCorrectWindowedSchema() {
    // Given:
    aggregateParams = new AggregateParamsFactory(udafFactory, undoUdafFactory).create(INPUT_SCHEMA, NON_AGG_COLUMNS, functionRegistry, FUNCTIONS, true, KsqlConfig.empty());
    // When:
    final LogicalSchema schema = aggregateParams.getSchema();
    // Then:
    assertThat(schema, equalTo(LogicalSchema.builder().keyColumns(INPUT_SCHEMA.key()).valueColumn(ColumnName.of("REQUIRED0"), SqlTypes.BIGINT).valueColumn(ColumnName.of("REQUIRED1"), SqlTypes.STRING).valueColumn(ColumnNames.aggregateColumn(0), SqlTypes.INTEGER).valueColumn(ColumnNames.aggregateColumn(1), SqlTypes.STRING).valueColumn(SystemColumns.WINDOWSTART_NAME, SystemColumns.WINDOWBOUND_TYPE).valueColumn(SystemColumns.WINDOWEND_NAME, SystemColumns.WINDOWBOUND_TYPE).build()));
}
Also used : LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Test(org.junit.Test)

Example 29 with LogicalSchema

use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.

the class AggregateParamsFactoryTest method shouldReturnCorrectSchema.

@Test
public void shouldReturnCorrectSchema() {
    // When:
    final LogicalSchema schema = aggregateParams.getSchema();
    // Then:
    assertThat(schema, equalTo(LogicalSchema.builder().keyColumns(INPUT_SCHEMA.key()).valueColumn(ColumnName.of("REQUIRED0"), SqlTypes.BIGINT).valueColumn(ColumnName.of("REQUIRED1"), SqlTypes.STRING).valueColumn(ColumnNames.aggregateColumn(0), SqlTypes.INTEGER).valueColumn(ColumnNames.aggregateColumn(1), SqlTypes.STRING).build()));
}
Also used : LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Test(org.junit.Test)

Example 30 with LogicalSchema

use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.

the class RowTest method shouldImplementEquals.

@SuppressWarnings("UnstableApiUsage")
@Test
public void shouldImplementEquals() {
    final LogicalSchema differentSchema = LogicalSchema.builder().keyColumn(ColumnName.of("k0"), SqlTypes.STRING).keyColumn(ColumnName.of("k1"), SqlTypes.INTEGER).valueColumn(ColumnName.of("diff0"), SqlTypes.STRING).valueColumn(ColumnName.of("diff1"), SqlTypes.DOUBLE).build();
    new EqualsTester().addEqualityGroup(Row.of(SCHEMA, A_KEY, A_VALUE, A_ROWTIME), Row.of(SCHEMA, A_KEY, A_VALUE, A_ROWTIME)).addEqualityGroup(Row.of(differentSchema, A_KEY, A_VALUE, A_ROWTIME)).addEqualityGroup(Row.of(SCHEMA, GenericKey.genericKey("diff", 11), A_VALUE, A_ROWTIME)).addEqualityGroup(Row.of(SCHEMA, A_KEY, GenericRow.genericRow(null, null), A_ROWTIME)).addEqualityGroup(Row.of(SCHEMA, A_KEY, A_VALUE, -1L)).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Test(org.junit.Test)

Aggregations

LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)223 Test (org.junit.Test)152 Expression (io.confluent.ksql.execution.expression.tree.Expression)44 ColumnName (io.confluent.ksql.name.ColumnName)31 GenericRow (io.confluent.ksql.GenericRow)30 UnqualifiedColumnReferenceExp (io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp)29 KsqlException (io.confluent.ksql.util.KsqlException)27 GenericKey (io.confluent.ksql.GenericKey)20 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)19 List (java.util.List)16 TimestampColumn (io.confluent.ksql.execution.timestamp.TimestampColumn)14 SqlType (io.confluent.ksql.schema.ksql.types.SqlType)14 Optional (java.util.Optional)14 Collectors (java.util.stream.Collectors)14 QueryContext (io.confluent.ksql.execution.context.QueryContext)13 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)12 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)12 SelectExpression (io.confluent.ksql.execution.plan.SelectExpression)12 Column (io.confluent.ksql.schema.ksql.Column)12 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)11