use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class InsertValuesExecutorTest method shouldThrowOnInsertHeaders.
@Test
public void shouldThrowOnInsertHeaders() {
// Given:
givenSourceStreamWithSchema(SCHEMA_WITH_HEADERS, SerdeFeatures.of(), SerdeFeatures.of());
final ConfiguredStatement<InsertValues> statement = givenInsertValues(allColumnNames(SCHEMA_WITH_HEADERS), 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.LongLiteral 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.LongLiteral in project ksql by confluentinc.
the class InsertValuesExecutorTest method shouldThrowIfNotEnoughValuesSuppliedWithNoSchema.
@Test
public void shouldThrowIfNotEnoughValuesSuppliedWithNoSchema() {
// Given:
final ConfiguredStatement<InsertValues> statement = givenInsertValues(ImmutableList.of(), ImmutableList.of(new LongLiteral(1L)));
// When:
final Exception e = assertThrows(KsqlException.class, () -> executor.execute(statement, mock(SessionProperties.class), engine, serviceContext));
// Then:
assertThat(e.getCause(), (hasMessage(containsString("Expected a value for each column"))));
}
use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class InsertValuesExecutorTest method shouldThrowWhenInsertValuesOnReservedInternalTopic.
@Test
public void shouldThrowWhenInsertValuesOnReservedInternalTopic() {
// Given
givenDataSourceWithSchema("_confluent-ksql-default__command-topic", SCHEMA, SerdeFeatures.of(), SerdeFeatures.of(), false, false);
final KsqlConfig ksqlConfig = new KsqlConfig(ImmutableMap.of());
final ConfiguredStatement<InsertValues> statement = ConfiguredStatement.of(PreparedStatement.of("", new InsertValues(SourceName.of("TOPIC"), allAndPseudoColumnNames(SCHEMA), ImmutableList.of(new LongLiteral(1L), new StringLiteral("str"), new StringLiteral("str"), new LongLiteral(2L)))), SessionConfig.of(ksqlConfig, ImmutableMap.of()));
// When:
final Exception e = assertThrows(KsqlException.class, () -> executor.execute(statement, mock(SessionProperties.class), engine, serviceContext));
// Then:
assertThat(e.getMessage(), containsString("Cannot insert values into read-only topic: _confluent-ksql-default__command-topic"));
}
use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class InterpretedExpressionTest method shouldEvaluateCastToInteger.
@Test
public void shouldEvaluateCastToInteger() {
// Given:
final Expression cast1 = new Cast(new LongLiteral(10L), new Type(SqlPrimitiveType.of("INTEGER")));
final Expression cast2 = new Cast(new StringLiteral("1234"), new Type(SqlPrimitiveType.of("INTEGER")));
final Expression cast3 = new Cast(new DoubleLiteral(12.5), new Type(SqlPrimitiveType.of("INTEGER")));
final Expression cast4 = new Cast(new DecimalLiteral(new BigDecimal("4567.5")), new Type(SqlPrimitiveType.of("INTEGER")));
// When:
InterpretedExpression interpreter1 = interpreter(cast1);
InterpretedExpression interpreter2 = interpreter(cast2);
InterpretedExpression interpreter3 = interpreter(cast3);
InterpretedExpression interpreter4 = interpreter(cast4);
// Then:
assertThat(interpreter1.evaluate(ROW), is(10));
assertThat(interpreter2.evaluate(ROW), is(1234));
assertThat(interpreter3.evaluate(ROW), is(12));
assertThat(interpreter4.evaluate(ROW), is(4567));
}
Aggregations