use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class CreateSourceAsPropertiesTest method shouldNotQuoteNonStringPropValues.
@Test
public void shouldNotQuoteNonStringPropValues() {
// Given:
final CreateSourceAsProperties props = CreateSourceAsProperties.from(ImmutableMap.of("Wrap_Single_value", new BooleanLiteral("true")));
// 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 InsertValuesExecutorTest method shouldHandleNullKeyForSourceWithKeyField.
@Test
public void shouldHandleNullKeyForSourceWithKeyField() {
// Given:
givenSourceStreamWithSchema(BIG_SCHEMA, SerdeFeatures.of(), SerdeFeatures.of());
final ConfiguredStatement<InsertValues> statement = givenInsertValues(allAndPseudoColumnNames(BIG_SCHEMA), ImmutableList.of(new LongLiteral(1L), new StringLiteral("str"), new StringLiteral("str"), new IntegerLiteral(0), new LongLiteral(2), new DoubleLiteral(3.0), new BooleanLiteral("TRUE"), new StringLiteral("str"), new DecimalLiteral(new BigDecimal("1.2"))));
// When:
executor.execute(statement, mock(SessionProperties.class), engine, serviceContext);
// Then:
verify(keySerializer).serialize(TOPIC_NAME, genericKey("str"));
verify(valueSerializer).serialize(TOPIC_NAME, genericRow("str", 0, 2L, 3.0, true, "str", new BigDecimal("1.2", new MathContext(2))));
verify(producer).send(new ProducerRecord<>(TOPIC_NAME, null, 1L, KEY, VALUE));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldNotCoerceStructOfIncompatibleLiterals.
@Test
public void shouldNotCoerceStructOfIncompatibleLiterals() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new CreateStructExpression(ImmutableList.of(new Field("a", new IntegerLiteral(10)))), new CreateStructExpression(ImmutableList.of(new Field("a", new BooleanLiteral(false)))));
// When:
final Exception e = assertThrows(KsqlException.class, () -> CoercionUtil.coerceUserList(expressions, typeManager));
// Then:
assertThat(e.getMessage(), startsWith("operator does not exist: STRUCT<`a` INTEGER> = STRUCT<`a` BOOLEAN> (STRUCT(a:=false))"));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldDriveCoercionFromFirstNonNullExpression.
@Test
public void shouldDriveCoercionFromFirstNonNullExpression() {
// Given:
final ImmutableList<Expression> stringFirst = ImmutableList.of(new NullLiteral(), new StringLiteral("false"), new BooleanLiteral(true));
final ImmutableList<Expression> boolFirst = ImmutableList.of(new NullLiteral(), new BooleanLiteral(true), new StringLiteral("false"));
// When:
final Result stringResult = CoercionUtil.coerceUserList(stringFirst, typeManager);
final Result boolResult = CoercionUtil.coerceUserList(boolFirst, typeManager);
// Then:
assertThat(stringResult.commonType(), is(Optional.of(SqlTypes.STRING)));
assertThat(stringResult.expressions(), is(ImmutableList.of(new NullLiteral(), new StringLiteral("false"), new StringLiteral("true"))));
assertThat(boolResult.commonType(), is(Optional.of(SqlTypes.BOOLEAN)));
assertThat(boolResult.expressions(), is(ImmutableList.of(new NullLiteral(), new BooleanLiteral(true), new BooleanLiteral(false))));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldNotCoerceArrayOfIncompatibleLiterals.
@Test
public void shouldNotCoerceArrayOfIncompatibleLiterals() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new CreateArrayExpression(ImmutableList.of(new IntegerLiteral(10))), new CreateArrayExpression(ImmutableList.of(new BooleanLiteral(false))));
// When:
final Exception e = assertThrows(KsqlException.class, () -> CoercionUtil.coerceUserList(expressions, typeManager));
// Then:
assertThat(e.getMessage(), startsWith("operator does not exist: ARRAY<INTEGER> = ARRAY<BOOLEAN> (ARRAY[false])"));
}
Aggregations