Search in sources :

Example 51 with LogicalSchema

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

the class StepSchemaResolverTest method shouldResolveSchemaForTableGroupByAnyKey.

@Test
public void shouldResolveSchemaForTableGroupByAnyKey() {
    // Given:
    final TableGroupBy<?> step = new TableGroupBy<>(PROPERTIES, tableSource, formats, ImmutableList.of(new UnqualifiedColumnReferenceExp(Optional.empty(), ORANGE_COL)));
    // When:
    final LogicalSchema result = resolver.resolve(step, SCHEMA);
    // Then:
    assertThat(result, is(LogicalSchema.builder().keyColumn(ORANGE_COL, SqlTypes.INTEGER).valueColumns(SCHEMA.value()).build()));
}
Also used : TableGroupBy(io.confluent.ksql.execution.plan.TableGroupBy) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Example 52 with LogicalSchema

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

the class StepSchemaResolverTest method shouldResolveSchemaForStreamGroupBy.

@Test
public void shouldResolveSchemaForStreamGroupBy() {
    // Given:
    final StreamGroupBy<?> step = new StreamGroupBy<>(PROPERTIES, streamSource, formats, ImmutableList.of(new UnqualifiedColumnReferenceExp(Optional.empty(), ORANGE_COL)));
    // When:
    final LogicalSchema result = resolver.resolve(step, SCHEMA);
    // Then:
    assertThat(result, is(LogicalSchema.builder().keyColumn(ORANGE_COL, SqlTypes.INTEGER).valueColumns(SCHEMA.value()).build()));
}
Also used : StreamGroupBy(io.confluent.ksql.execution.plan.StreamGroupBy) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Example 53 with LogicalSchema

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

the class StepSchemaResolverTest method shouldResolveSchemaForStreamSelectKeyV2.

@Test
public void shouldResolveSchemaForStreamSelectKeyV2() {
    // Given:
    final UnqualifiedColumnReferenceExp keyExpression1 = new UnqualifiedColumnReferenceExp(ColumnName.of("ORANGE"));
    final UnqualifiedColumnReferenceExp keyExpression2 = new UnqualifiedColumnReferenceExp(ColumnName.of("APPLE"));
    final StreamSelectKey<GenericKey> step = new StreamSelectKey<>(PROPERTIES, streamSource, ImmutableList.of(keyExpression1, keyExpression2));
    // When:
    final LogicalSchema result = resolver.resolve(step, SCHEMA);
    // Then:
    assertThat(result, is(LogicalSchema.builder().keyColumn(keyExpression1.getColumnName(), SqlTypes.INTEGER).keyColumn(keyExpression2.getColumnName(), SqlTypes.BIGINT).valueColumns(SCHEMA.value()).build()));
}
Also used : LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) GenericKey(io.confluent.ksql.GenericKey) StreamSelectKey(io.confluent.ksql.execution.plan.StreamSelectKey) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Example 54 with LogicalSchema

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

the class StepSchemaResolverTest method shouldResolveSchemaForTableSelect.

@Test
public void shouldResolveSchemaForTableSelect() {
    // Given:
    final TableSelect<?> step = new TableSelect<>(PROPERTIES, tableSource, ImmutableList.of(), ImmutableList.of(add("JUICE", "ORANGE", "APPLE"), ref("PLANTAIN", "BANANA"), ref("CITRUS", "ORANGE")), internalFormats);
    // When:
    final LogicalSchema result = resolver.resolve(step, SCHEMA);
    // Then:
    assertThat(result, is(LogicalSchema.builder().keyColumn(ColumnName.of("K0"), SqlTypes.INTEGER).valueColumn(ColumnName.of("JUICE"), SqlTypes.BIGINT).valueColumn(ColumnName.of("PLANTAIN"), SqlTypes.STRING).valueColumn(ColumnName.of("CITRUS"), SqlTypes.INTEGER).build()));
}
Also used : TableSelect(io.confluent.ksql.execution.plan.TableSelect) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) Test(org.junit.Test)

Example 55 with LogicalSchema

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

the class StepSchemaResolverTest method shouldResolveSchemaForTableGroupBy.

@Test
public void shouldResolveSchemaForTableGroupBy() {
    // Given:
    final TableGroupBy<?> step = new TableGroupBy<>(PROPERTIES, tableSource, formats, ImmutableList.of(new UnqualifiedColumnReferenceExp(Optional.empty(), ORANGE_COL)));
    // When:
    final LogicalSchema result = resolver.resolve(step, SCHEMA);
    // Then:
    assertThat(result, is(LogicalSchema.builder().keyColumn(ORANGE_COL, SqlTypes.INTEGER).valueColumns(SCHEMA.value()).build()));
}
Also used : TableGroupBy(io.confluent.ksql.execution.plan.TableGroupBy) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) 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