Search in sources :

Example 86 with UnqualifiedColumnReferenceExp

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);
}
Also used : UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Before(org.junit.Before)

Example 87 with UnqualifiedColumnReferenceExp

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()));
}
Also used : Field(io.confluent.ksql.execution.expression.tree.CreateStructExpression.Field) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) CreateMapExpression(io.confluent.ksql.execution.expression.tree.CreateMapExpression) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) CreateArrayExpression(io.confluent.ksql.execution.expression.tree.CreateArrayExpression) CreateStructExpression(io.confluent.ksql.execution.expression.tree.CreateStructExpression) NotExpression(io.confluent.ksql.execution.expression.tree.NotExpression) SimpleCaseExpression(io.confluent.ksql.execution.expression.tree.SimpleCaseExpression) SubscriptExpression(io.confluent.ksql.execution.expression.tree.SubscriptExpression) InListExpression(io.confluent.ksql.execution.expression.tree.InListExpression) ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) SearchedCaseExpression(io.confluent.ksql.execution.expression.tree.SearchedCaseExpression) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) CreateStructExpression(io.confluent.ksql.execution.expression.tree.CreateStructExpression) SqlType(io.confluent.ksql.schema.ksql.types.SqlType) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Example 88 with UnqualifiedColumnReferenceExp

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));
}
Also used : DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) CreateMapExpression(io.confluent.ksql.execution.expression.tree.CreateMapExpression) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) CreateArrayExpression(io.confluent.ksql.execution.expression.tree.CreateArrayExpression) CreateStructExpression(io.confluent.ksql.execution.expression.tree.CreateStructExpression) NotExpression(io.confluent.ksql.execution.expression.tree.NotExpression) SimpleCaseExpression(io.confluent.ksql.execution.expression.tree.SimpleCaseExpression) SubscriptExpression(io.confluent.ksql.execution.expression.tree.SubscriptExpression) InListExpression(io.confluent.ksql.execution.expression.tree.InListExpression) ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) SearchedCaseExpression(io.confluent.ksql.execution.expression.tree.SearchedCaseExpression) SqlType(io.confluent.ksql.schema.ksql.types.SqlType) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Example 89 with UnqualifiedColumnReferenceExp

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));
}
Also used : ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) LogicalBinaryExpression(io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) CreateMapExpression(io.confluent.ksql.execution.expression.tree.CreateMapExpression) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) ArithmeticUnaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression) CreateArrayExpression(io.confluent.ksql.execution.expression.tree.CreateArrayExpression) CreateStructExpression(io.confluent.ksql.execution.expression.tree.CreateStructExpression) NotExpression(io.confluent.ksql.execution.expression.tree.NotExpression) SimpleCaseExpression(io.confluent.ksql.execution.expression.tree.SimpleCaseExpression) SubscriptExpression(io.confluent.ksql.execution.expression.tree.SubscriptExpression) InListExpression(io.confluent.ksql.execution.expression.tree.InListExpression) ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) SearchedCaseExpression(io.confluent.ksql.execution.expression.tree.SearchedCaseExpression) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Example 90 with UnqualifiedColumnReferenceExp

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);
}
Also used : UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Aggregations

UnqualifiedColumnReferenceExp (io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp)152 Test (org.junit.Test)138 Expression (io.confluent.ksql.execution.expression.tree.Expression)85 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)79 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)59 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)57 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)55 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)45 KsqlException (io.confluent.ksql.util.KsqlException)32 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)29 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)26 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)22 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)18 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)17 GenericKey (io.confluent.ksql.GenericKey)12 WindowBounds (io.confluent.ksql.planner.plan.QueryFilterNode.WindowBounds)12 GenericRow (io.confluent.ksql.GenericRow)11 PlanNode (io.confluent.ksql.planner.plan.PlanNode)11 WindowRange (io.confluent.ksql.planner.plan.QueryFilterNode.WindowBounds.WindowRange)11 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)10