use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldEvaluateTypeForCreateArrayExpression.
@Test
public void shouldEvaluateTypeForCreateArrayExpression() {
// Given:
Expression expression = new CreateArrayExpression(ImmutableList.of(new UnqualifiedColumnReferenceExp(COL0)));
// 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 ExpressionTypeManagerTest method shouldEvaluateTypeForCreateMapExpression.
@Test
public void shouldEvaluateTypeForCreateMapExpression() {
// Given:
Expression expression = new CreateMapExpression(ImmutableMap.of(COL3, new UnqualifiedColumnReferenceExp(COL0)));
// When:
final SqlType type = expressionTypeManager.getExpressionSqlType(expression);
// Then:
assertThat(type, is(SqlTypes.map(SqlTypes.DOUBLE, SqlTypes.BIGINT)));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldFailIfThereIsInvalidFieldNameInStructCall.
@Test
public void shouldFailIfThereIsInvalidFieldNameInStructCall() {
// Given:
final Expression expression = new DereferenceExpression(Optional.empty(), new UnqualifiedColumnReferenceExp(ColumnName.of("COL6")), "ZIP");
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
// Then:
assertThat(e.getMessage(), containsString("Could not find field 'ZIP' in 'COL6'."));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldThrowOnMapOfMultipleTypes.
@Test
public void shouldThrowOnMapOfMultipleTypes() {
// Given:
Expression expression = new CreateMapExpression(ImmutableMap.of(new StringLiteral("foo"), new UnqualifiedColumnReferenceExp(COL0), new StringLiteral("bar"), new StringLiteral("bar")));
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
// Then:
assertThat(e.getMessage(), containsString("invalid input syntax for type BIGINT: \"bar\""));
}
use of io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldThrowOnArrayMultipleTypes.
@Test
public void shouldThrowOnArrayMultipleTypes() {
// Given:
Expression expression = new CreateArrayExpression(ImmutableList.of(new UnqualifiedColumnReferenceExp(COL0), new StringLiteral("foo")));
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
// Then:
assertThat(e.getMessage(), containsString("invalid input syntax for type BIGINT: \"foo\"."));
}
Aggregations