use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldEvaluateTypeForArrayReferenceInStruct.
@Test
public void shouldEvaluateTypeForArrayReferenceInStruct() {
// Given:
final SqlStruct inner = SqlTypes.struct().field("IN0", SqlTypes.array(SqlTypes.INTEGER)).build();
final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(COL0, inner).build();
expressionTypeManager = new ExpressionTypeManager(schema, functionRegistry);
final Expression structRef = new DereferenceExpression(Optional.empty(), new UnqualifiedColumnReferenceExp(COL0), "IN0");
final Expression expression = new SubscriptExpression(structRef, new IntegerLiteral(1));
// When:
final SqlType result = expressionTypeManager.getExpressionSqlType(expression);
// Then:
assertThat(result, is(SqlTypes.INTEGER));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldEvaluateTypeForCreateArrayExpressionWithNull.
@Test
public void shouldEvaluateTypeForCreateArrayExpressionWithNull() {
// Given:
Expression expression = new CreateArrayExpression(ImmutableList.of(new UnqualifiedColumnReferenceExp(COL0), new NullLiteral()));
// When:
final SqlType type = expressionTypeManager.getExpressionSqlType(expression);
// Then:
assertThat(type, is(SqlTypes.array(SqlTypes.BIGINT)));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SchemaKStreamTest method shouldRewriteTimeComparisonInFilter.
@Test
@SuppressWarnings("rawtypes")
public void shouldRewriteTimeComparisonInFilter() {
// Given:
final PlanNode logicalPlan = givenInitialKStreamOf("SELECT col0, col2, col3 FROM test1 " + "WHERE ROWTIME = '1984-01-01T00:00:00+00:00' EMIT CHANGES;");
final FilterNode filterNode = (FilterNode) logicalPlan.getSources().get(0).getSources().get(0);
// When:
final SchemaKStream<?> filteredSchemaKStream = initialSchemaKStream.filter(filterNode.getPredicate(), childContextStacker);
// Then:
final StreamFilter step = (StreamFilter) filteredSchemaKStream.getSourceStep();
assertThat(step.getFilterExpression(), equalTo(new ComparisonExpression(ComparisonExpression.Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("ROWTIME")), new LongLiteral(441763200000L))));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SchemaKStreamTest method shouldBuildStepForGroupByKey.
@Test
public void shouldBuildStepForGroupByKey() {
// Given:
givenInitialKStreamOf("SELECT col0, col1 FROM test1 WHERE col0 > 100 EMIT CHANGES;");
final List<Expression> groupBy = Collections.singletonList(new UnqualifiedColumnReferenceExp(ColumnName.of("COL0")));
// When:
final SchemaKGroupedStream groupedSchemaKStream = initialSchemaKStream.groupBy(valueFormat.getFormatInfo(), groupBy, childContextStacker);
// Then:
assertThat(groupedSchemaKStream.getSourceStep(), equalTo(ExecutionStepFactory.streamGroupByKey(childContextStacker, initialSchemaKStream.getSourceStep(), Formats.of(keyFormat.getFormatInfo(), valueFormat.getFormatInfo(), SerdeFeatures.of(), SerdeFeatures.of()))));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SchemaKStreamTest method shouldBuildStepForGroupBy.
@Test
public void shouldBuildStepForGroupBy() {
// Given:
givenInitialKStreamOf("SELECT col0, col1 FROM test1 WHERE col0 > 100 EMIT CHANGES;");
final List<Expression> groupBy = Collections.singletonList(new UnqualifiedColumnReferenceExp(ColumnName.of("COL1")));
// When:
final SchemaKGroupedStream groupedSchemaKStream = initialSchemaKStream.groupBy(valueFormat.getFormatInfo(), groupBy, childContextStacker);
// Then:
assertThat(groupedSchemaKStream.getSourceStep(), equalTo(ExecutionStepFactory.streamGroupBy(childContextStacker, initialSchemaKStream.getSourceStep(), Formats.of(keyFormat.getFormatInfo(), valueFormat.getFormatInfo(), SerdeFeatures.of(), SerdeFeatures.of()), groupBy)));
}
Aggregations