use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp 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()));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp 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.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class PartitionByParamsFactoryTest method shouldAppendNewKeyColumnsToValueIfPartitioningByMixOfColumnsAndExpressions.
@Test
public void shouldAppendNewKeyColumnsToValueIfPartitioningByMixOfColumnsAndExpressions() {
// Given:
final Mapper<GenericKey> mapper = partitionBy(ImmutableList.of(new ArithmeticBinaryExpression(Operator.ADD, new UnqualifiedColumnReferenceExp(COL0), new StringLiteral("-foo")), new UnqualifiedColumnReferenceExp(COL1), new FunctionCall(CONSTANT_UDF_NAME, ImmutableList.of(new UnqualifiedColumnReferenceExp(COL1))))).getMapper();
final ImmutableList<Object> originals = ImmutableList.copyOf(value.values());
// When:
final KeyValue<GenericKey, GenericRow> result = mapper.apply(key, value);
// Then:
assertThat(result.value, is(GenericRow.fromList(originals).append(OLD_KEY + "-foo").append(ConstantUdf.VALUE)));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class PartitionByParamsFactoryTest method shouldPropagateNullValueWhenPartitioningByMixOfKeyAndNonKeyExpressions.
@Test
public void shouldPropagateNullValueWhenPartitioningByMixOfKeyAndNonKeyExpressions() {
// Given:
final Mapper<GenericKey> mapper = partitionBy(ImmutableList.of(new ArithmeticBinaryExpression(Operator.ADD, new UnqualifiedColumnReferenceExp(COL0), new StringLiteral("-foo")), new UnqualifiedColumnReferenceExp(COL1))).getMapper();
// When:
final KeyValue<GenericKey, GenericRow> result = mapper.apply(key, null);
// Then:
assertThat(result.key, is(genericKey(OLD_KEY + "-foo", null)));
assertThat(result.value, is(nullValue()));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class PartitionByParamsFactoryTest method shouldPropagateNullValueWhenPartitioningByKeyExpression.
@Test
public void shouldPropagateNullValueWhenPartitioningByKeyExpression() {
// Given:
final Mapper<GenericKey> mapper = partitionBy(ImmutableList.of(new ArithmeticBinaryExpression(Operator.ADD, new UnqualifiedColumnReferenceExp(COL0), new StringLiteral("-foo")))).getMapper();
// When:
final KeyValue<GenericKey, GenericRow> result = mapper.apply(key, null);
// Then:
assertThat(result.key, is(genericKey((OLD_KEY + "-foo"))));
assertThat(result.value, is(nullValue()));
}
Aggregations