use of io.confluent.ksql.execution.expression.tree.CreateMapExpression 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.CreateMapExpression in project ksql by confluentinc.
the class CoercionUtilTest method shouldNotCoerceMapOfIncompatibleKeyLiterals.
@Test
public void shouldNotCoerceMapOfIncompatibleKeyLiterals() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new CreateMapExpression(ImmutableMap.of(new IntegerLiteral(10), new IntegerLiteral(289476))), new CreateMapExpression(ImmutableMap.of(new BooleanLiteral(false), new StringLiteral("123456789000"))));
// When:
final Exception e = assertThrows(KsqlException.class, () -> CoercionUtil.coerceUserList(expressions, typeManager));
// Then:
assertThat(e.getMessage(), startsWith("operator does not exist: MAP<INTEGER, INTEGER> = MAP<BOOLEAN, STRING> (MAP(false:='123456789000'))"));
}
use of io.confluent.ksql.execution.expression.tree.CreateMapExpression in project ksql by confluentinc.
the class CoercionUtilTest method shouldNotCoerceMapWithDifferentKeyExpression.
@Test
public void shouldNotCoerceMapWithDifferentKeyExpression() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new CreateMapExpression(ImmutableMap.of(new IntegerLiteral(10), new IntegerLiteral(10))), new CreateMapExpression(ImmutableMap.of(STRING_EXPRESSION, new IntegerLiteral(10))));
// When:
final Exception e = assertThrows(KsqlException.class, () -> CoercionUtil.coerceUserList(expressions, typeManager));
// Then:
assertThat(e.getMessage(), startsWith("operator does not exist: MAP<INTEGER, INTEGER> = MAP<STRING, INTEGER> (MAP(STR:=10))"));
}
use of io.confluent.ksql.execution.expression.tree.CreateMapExpression in project ksql by confluentinc.
the class CoercionUtilTest method shouldCoerceMapOfCompatibleLiterals.
@Test
public void shouldCoerceMapOfCompatibleLiterals() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new CreateMapExpression(ImmutableMap.of(new IntegerLiteral(10), new IntegerLiteral(289476))), new CreateMapExpression(ImmutableMap.of(new StringLiteral("123456789000"), new StringLiteral("\t -100 \t"))));
// When:
final Result result = CoercionUtil.coerceUserList(expressions, typeManager);
// Then:
assertThat(result.commonType(), is(Optional.of(SqlTypes.map(SqlTypes.BIGINT, SqlTypes.INTEGER))));
assertThat(result.expressions(), is(ImmutableList.of(cast(new CreateMapExpression(ImmutableMap.of(new IntegerLiteral(10), new IntegerLiteral(289476))), SqlTypes.map(SqlTypes.BIGINT, SqlTypes.INTEGER)), cast(new CreateMapExpression(ImmutableMap.of(new StringLiteral("123456789000"), new StringLiteral("\t -100 \t"))), SqlTypes.map(SqlTypes.BIGINT, SqlTypes.INTEGER)))));
}
use of io.confluent.ksql.execution.expression.tree.CreateMapExpression in project ksql by confluentinc.
the class CoercionUtilTest method shouldNotCoerceMapOfIncompatibleValueLiterals.
@Test
public void shouldNotCoerceMapOfIncompatibleValueLiterals() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new CreateMapExpression(ImmutableMap.of(new IntegerLiteral(10), new IntegerLiteral(289476))), new CreateMapExpression(ImmutableMap.of(new StringLiteral("123456789000"), new BooleanLiteral(false))));
// When:
final Exception e = assertThrows(KsqlException.class, () -> CoercionUtil.coerceUserList(expressions, typeManager));
// Then:
assertThat(e.getMessage(), startsWith("operator does not exist: MAP<INTEGER, INTEGER> = MAP<STRING, BOOLEAN> (MAP('123456789000':=false))"));
}
Aggregations