use of io.confluent.ksql.execution.expression.tree.CreateArrayExpression in project ksql by confluentinc.
the class CoercionUtilTest method shouldNotCoerceArrayWithDifferentExpression.
@Test
public void shouldNotCoerceArrayWithDifferentExpression() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new CreateArrayExpression(ImmutableList.of(new IntegerLiteral(10))), new CreateArrayExpression(ImmutableList.of(STRING_EXPRESSION)));
// When:
final Exception e = assertThrows(KsqlException.class, () -> CoercionUtil.coerceUserList(expressions, typeManager));
// Then:
assertThat(e.getMessage(), startsWith("operator does not exist: ARRAY<INTEGER> = ARRAY<STRING> (ARRAY[STR])"));
}
use of io.confluent.ksql.execution.expression.tree.CreateArrayExpression in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldThrowOnArrayAllNulls.
@Test
public void shouldThrowOnArrayAllNulls() {
// Given:
Expression expression = new CreateArrayExpression(ImmutableList.of(new NullLiteral()));
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
// Then:
assertThat(e.getMessage(), containsString("Cannot construct an array with all NULL elements"));
}
use of io.confluent.ksql.execution.expression.tree.CreateArrayExpression 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.CreateArrayExpression 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\"."));
}
use of io.confluent.ksql.execution.expression.tree.CreateArrayExpression 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)));
}
Aggregations