use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class SelectValueMapperTest method setup.
@Before
public void setup() {
when(col0.getExpression()).thenReturn(new UnqualifiedColumnReferenceExp(ColumnName.of("a")));
when(col1.getExpression()).thenReturn(new UnqualifiedColumnReferenceExp(ColumnName.of("c")));
when(col2.getExpression()).thenReturn(new UnqualifiedColumnReferenceExp(ColumnName.of("b")));
final SelectValueMapper<Object> selectValueMapper = new SelectValueMapper<>(ImmutableList.of(SelectValueMapper.SelectInfo.of(NAME0, col0), SelectValueMapper.SelectInfo.of(NAME1, col1), SelectValueMapper.SelectInfo.of(NAME2, col2)));
transformer = selectValueMapper.getTransformer(processingLogger);
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldEvaluateTypeForStructExpression.
@Test
public void shouldEvaluateTypeForStructExpression() {
// Given:
final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(COL0, SqlTypes.array(SqlTypes.INTEGER)).build();
expressionTypeManager = new ExpressionTypeManager(schema, functionRegistry);
final Expression exp = new CreateStructExpression(ImmutableList.of(new Field("field1", new StringLiteral("foo")), new Field("field2", new UnqualifiedColumnReferenceExp(COL0)), new Field("field3", new CreateStructExpression(ImmutableList.of()))));
// When:
final SqlType sqlType = expressionTypeManager.getExpressionSqlType(exp);
// Then:
assertThat(sqlType, is(SqlTypes.struct().field("field1", SqlTypes.STRING).field("field2", SqlTypes.array(SqlTypes.INTEGER)).field("field3", SqlTypes.struct().build()).build()));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldHandleStructFieldDereference.
@Test
public void shouldHandleStructFieldDereference() {
// Given:
final Expression expression = new DereferenceExpression(Optional.empty(), new UnqualifiedColumnReferenceExp(ColumnName.of("COL6")), "STREET");
// When:
final SqlType result = expressionTypeManager.getExpressionSqlType(expression);
assertThat(result, is(SqlTypes.STRING));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTreeRewriterTest method shouldRewriteColumnReference.
@Test
public void shouldRewriteColumnReference() {
// Given:
final UnqualifiedColumnReferenceExp expression = new UnqualifiedColumnReferenceExp(ColumnName.of("foo"));
// When:
final Expression rewritten = expressionRewriter.rewrite(expression, context);
// Then:
assertThat(rewritten, is(expression));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTreeRewriterTest method shouldRewriteColumnReferenceUsingPlugin.
@Test
public void shouldRewriteColumnReferenceUsingPlugin() {
// Given:
final UnqualifiedColumnReferenceExp expression = new UnqualifiedColumnReferenceExp(ColumnName.of("foo"));
// When/Then:
shouldRewriteUsingPlugin(expression);
}
Aggregations