use of io.confluent.ksql.execution.expression.tree.StringLiteral 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.StringLiteral 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.StringLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldFailIfInvalidConfig.
@Test
public void shouldFailIfInvalidConfig() {
// When:
final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put("foo", new StringLiteral("bar")).build()));
// Then:
assertThat(e.getMessage(), containsString("Invalid config variable(s) in the WITH clause: FOO"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldGetKeyAndValueSchemaIdFromFormat.
@Test
public void shouldGetKeyAndValueSchemaIdFromFormat() {
// Given:
final CreateSourceProperties props = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(FORMAT_PROPERTY, new StringLiteral("AVRO")).put(KEY_SCHEMA_ID, new IntegerLiteral(123)).put(VALUE_SCHEMA_ID, new IntegerLiteral(456)).build());
// When / Then:
assertThat(props.getKeyFormat(SourceName.of("foo")).get().getProperties(), hasEntry(ConnectProperties.SCHEMA_ID, "123"));
assertThat(props.getValueFormat().get().getProperties(), hasEntry(ConnectProperties.SCHEMA_ID, "456"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldHandleNonUpperCasePropNames.
@Test
public void shouldHandleNonUpperCasePropNames() {
// When:
final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.WRAP_SINGLE_VALUE.toLowerCase(), new StringLiteral("false")).build());
// Then:
assertThat(properties.getValueSerdeFeatures(), is(SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES)));
}
Aggregations