use of io.confluent.ksql.execution.expression.tree.NullLiteral in project ksql by confluentinc.
the class InsertValuesExecutorTest method shouldThrowOnInsertAllWithHeaders.
@Test
public void shouldThrowOnInsertAllWithHeaders() {
// Given:
givenSourceStreamWithSchema(SCHEMA_WITH_HEADERS, SerdeFeatures.of(), SerdeFeatures.of());
final ConfiguredStatement<InsertValues> statement = givenInsertValues(ImmutableList.of(), ImmutableList.of(new StringLiteral("key"), new StringLiteral("str"), new LongLiteral(2L), new NullLiteral()));
// When:
final Exception e = assertThrows(KsqlException.class, () -> executor.execute(statement, mock(SessionProperties.class), engine, serviceContext));
// Then:
assertThat(e.getMessage(), is("Cannot insert into HEADER columns: HEAD0"));
}
use of io.confluent.ksql.execution.expression.tree.NullLiteral 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.NullLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldHandleOnlyNulls.
@Test
public void shouldHandleOnlyNulls() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new NullLiteral(), new NullLiteral());
// When:
final Result result = CoercionUtil.coerceUserList(expressions, typeManager);
// Then:
assertThat(result.commonType(), is(Optional.empty()));
assertThat(result.expressions(), is(ImmutableList.of(new NullLiteral(), new NullLiteral())));
}
use of io.confluent.ksql.execution.expression.tree.NullLiteral in project ksql by confluentinc.
the class PartitionByParamsFactoryTest method shouldNotChangeValueIfPartitioningByNull.
@Test
public void shouldNotChangeValueIfPartitioningByNull() {
// Given:
final Mapper<GenericKey> mapper = partitionBy(ImmutableList.of(new NullLiteral())).getMapper();
final ImmutableList<Object> originals = ImmutableList.copyOf(value.values());
// When:
final KeyValue<GenericKey, GenericRow> result = mapper.apply(key, value);
// Then:
assertThat(result.value, is(GenericRow.fromList(originals)));
}
use of io.confluent.ksql.execution.expression.tree.NullLiteral in project ksql by confluentinc.
the class PartitionByParamsFactoryTest method shouldThrowIfPartitioningByMultipleExpressionsIncludingNull.
@Test
public void shouldThrowIfPartitioningByMultipleExpressionsIncludingNull() {
// Given:
final List<Expression> partitionBy = ImmutableList.of(new UnqualifiedColumnReferenceExp(COL1), new NullLiteral());
// Expect / When:
final Exception e = assertThrows(KsqlException.class, () -> PartitionByParamsFactory.buildSchema(SCHEMA, partitionBy, functionRegistry));
// Then:
assertThat(e.getMessage(), containsString("Cannot PARTITION BY multiple columns including NULL"));
}
Aggregations