use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.
the class StepSchemaResolverTest method shouldResolveSchemaForTableSourceV1.
@Test
public void shouldResolveSchemaForTableSourceV1() {
// Given:
final TableSourceV1 step = new TableSourceV1(PROPERTIES, "foo", formats, Optional.empty(), SCHEMA, Optional.of(true), OptionalInt.of(SystemColumns.CURRENT_PSEUDOCOLUMN_VERSION_NUMBER));
// When:
final LogicalSchema result = resolver.resolve(step, SCHEMA);
// Then:
assertThat(result, is(SCHEMA.withPseudoAndKeyColsInValue(false)));
}
use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.
the class StepSchemaResolverTest method shouldResolveSchemaForStreamSelectWithoutColumnNames.
@Test
public void shouldResolveSchemaForStreamSelectWithoutColumnNames() {
// Given:
final StreamSelect<?> step = new StreamSelect<>(PROPERTIES, streamSource, ImmutableList.of(ColumnName.of("NEW_KEY")), ImmutableList.of(add("JUICE", "ORANGE", "APPLE"), ref("PLANTAIN", "BANANA"), ref("CITRUS", "ORANGE")));
// When:
final LogicalSchema result = resolver.resolve(step, SCHEMA);
// Then:
assertThat(result, is(LogicalSchema.builder().keyColumn(ColumnName.of("NEW_KEY"), SqlTypes.INTEGER).valueColumn(ColumnName.of("JUICE"), SqlTypes.BIGINT).valueColumn(ColumnName.of("PLANTAIN"), SqlTypes.STRING).valueColumn(ColumnName.of("CITRUS"), SqlTypes.INTEGER).build()));
}
use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.
the class StepSchemaResolverTest method shouldResolveSchemaForStreamSource.
@Test
public void shouldResolveSchemaForStreamSource() {
final StreamSource step = new StreamSource(PROPERTIES, "foo", formats, Optional.empty(), SCHEMA, OptionalInt.of(SystemColumns.CURRENT_PSEUDOCOLUMN_VERSION_NUMBER));
// When:
final LogicalSchema result = resolver.resolve(step, SCHEMA);
// Then:
assertThat(result, is(SCHEMA.withPseudoAndKeyColsInValue(false)));
}
use of io.confluent.ksql.schema.ksql.LogicalSchema in project ksql by confluentinc.
the class StepSchemaResolverTest method shouldResolveSchemaForTableSelectKey.
@Test
public void shouldResolveSchemaForTableSelectKey() {
// Given:
final UnqualifiedColumnReferenceExp keyExpression1 = new UnqualifiedColumnReferenceExp(ColumnName.of("ORANGE"));
final UnqualifiedColumnReferenceExp keyExpression2 = new UnqualifiedColumnReferenceExp(ColumnName.of("APPLE"));
final TableSelectKey<GenericKey> step = new TableSelectKey<>(PROPERTIES, tableSource, formats, 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()));
}
use of io.confluent.ksql.schema.ksql.LogicalSchema 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()));
}
Aggregations