use of io.confluent.ksql.execution.expression.tree.BooleanLiteral 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))"));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldNotCoerceStringExpressionToBoolean.
@Test
public void shouldNotCoerceStringExpressionToBoolean() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new BooleanLiteral(true), STRING_EXPRESSION);
// When:
final Exception e = assertThrows(KsqlException.class, () -> CoercionUtil.coerceUserList(expressions, typeManager));
// Then:
assertThat(e.getMessage(), startsWith("operator does not exist: BOOLEAN = STRING (STR)"));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldFailIfDefaultHasDifferentTypeToWhen.
@Test
public void shouldFailIfDefaultHasDifferentTypeToWhen() {
// Given:
final Expression expression = new SearchedCaseExpression(ImmutableList.of(new WhenClause(new ComparisonExpression(Type.EQUAL, TestExpressions.COL0, new IntegerLiteral(10)), new StringLiteral("good"))), Optional.of(new BooleanLiteral("true")));
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
// Then:
assertThat(e.getMessage(), containsString("Invalid Case expression. Type for the default clause should be the same as for 'THEN' clauses." + System.lineSeparator() + "THEN type: STRING." + System.lineSeparator() + "DEFAULT type: BOOLEAN."));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldNotQuoteNonStringPropValues.
@Test
public void shouldNotQuoteNonStringPropValues() {
// Given:
final CreateSourceProperties props = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put("Wrap_Single_value", new BooleanLiteral("true")).build());
// When:
final String sql = props.toString();
// Then:
assertThat(sql, containsString("WRAP_SINGLE_VALUE=true"));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldSetWrapSingleValues.
@Test
public void shouldSetWrapSingleValues() {
// When:
final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.WRAP_SINGLE_VALUE, new BooleanLiteral("true")).build());
// Then:
assertThat(properties.getValueSerdeFeatures(), is(SerdeFeatures.of(SerdeFeature.WRAP_SINGLES)));
}
Aggregations