use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class DefaultSchemaInjectorTest method shouldThrowIfValueFormatDoesNotSupportSchemaIdInference.
@Test
public void shouldThrowIfValueFormatDoesNotSupportSchemaIdInference() {
// Given
givenKeyButNotValueInferenceSupported(ImmutableMap.of("value_schema_id", new IntegerLiteral(123), "WRAP_SINGLE_VALUE", new BooleanLiteral(true)));
when(cs.getElements()).thenReturn(SOME_KEY_ELEMENTS_STREAM);
// When:
final Exception e = assertThrows(KsqlException.class, () -> injector.inject(csStatement));
// Then:
assertThat(e.getMessage(), containsString("VALUE_FORMAT should support schema inference when VALUE_SCHEMA_ID is provided. " + "Current format is DELIMITED."));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldFailIfOperatorCannotBeAppiled.
@Test
public void shouldFailIfOperatorCannotBeAppiled() {
// Given:
final ComparisonExpression expr = new ComparisonExpression(Type.GREATER_THAN, new BooleanLiteral("true"), new BooleanLiteral("false"));
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expr));
// Then:
assertThat(e.getMessage(), containsString("Cannot compare true (BOOLEAN) to false (BOOLEAN) with " + "GREATER_THAN"));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldCoerceToBooleans.
@Test
public void shouldCoerceToBooleans() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new BooleanLiteral(true), new StringLiteral("FaLsE"), BOOL_EXPRESSION);
// When:
final Result result = CoercionUtil.coerceUserList(expressions, typeManager);
// Then:
assertThat(result.commonType(), is(Optional.of(SqlTypes.BOOLEAN)));
assertThat(result.expressions(), is(ImmutableList.of(new BooleanLiteral(true), new BooleanLiteral(false), BOOL_EXPRESSION)));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral 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.BooleanLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldThrowOnIncompatible.
@Test
public void shouldThrowOnIncompatible() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new BooleanLiteral(true), // <-- can not be coerced to boolean.
new IntegerLiteral(10));
// When:
final Exception e = assertThrows(KsqlException.class, () -> CoercionUtil.coerceUserList(expressions, typeManager));
// Then:
assertThat(e.getMessage(), is("operator does not exist: BOOLEAN = INTEGER (10)" + System.lineSeparator() + "Hint: You might need to add explicit type casts."));
}
Aggregations