use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class InsertValuesExecutorTest method shouldThrowWhenInsertingValuesOnSourceStream.
@Test
public void shouldThrowWhenInsertingValuesOnSourceStream() {
// Given:
givenDataSourceWithSchema("source_stream_1", SCHEMA, SerdeFeatures.of(), SerdeFeatures.of(), false, true);
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 stream: TOPIC"));
}
use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class InsertValuesExecutorTest method shouldThrowOnTablesWithKeyFieldAndNullKeyFieldValueProvided.
@Test
public void shouldThrowOnTablesWithKeyFieldAndNullKeyFieldValueProvided() {
// Given:
givenSourceTableWithSchema(SerdeFeatures.of(), SerdeFeatures.of());
final ConfiguredStatement<InsertValues> statement = givenInsertValues(ImmutableList.of(COL1), ImmutableList.of(new LongLiteral(2L)));
// When:
final Exception e = assertThrows(KsqlException.class, () -> executor.execute(statement, mock(SessionProperties.class), engine, serviceContext));
// Then:
assertThat(e.getMessage(), containsString("Failed to insert values into 'TOPIC'. Value for primary key column(s) k0 is required for tables"));
}
use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class InsertValuesExecutorTest method shouldThrowWhenInsertValuesOnProcessingLogTopic.
@Test
public void shouldThrowWhenInsertValuesOnProcessingLogTopic() {
// Given
givenDataSourceWithSchema("default_ksql_processing_log", 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: default_ksql_processing_log"));
}
use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class InsertValuesExecutorTest method shouldThrowOnSerializingValueError.
@Test
public void shouldThrowOnSerializingValueError() {
// Given:
final ConfiguredStatement<InsertValues> statement = givenInsertValues(allAndPseudoColumnNames(SCHEMA), ImmutableList.of(new LongLiteral(1L), new StringLiteral("str"), new StringLiteral("str"), new LongLiteral(2L)));
when(valueSerializer.serialize(any(), any())).thenThrow(new SerializationException("Jibberish!"));
// When:
final Exception e = assertThrows(KsqlException.class, () -> executor.execute(statement, mock(SessionProperties.class), engine, serviceContext));
// Then:
assertThat(e.getCause(), (hasMessage(containsString("Could not serialize value"))));
}
use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldCoerceToBigInts.
@Test
public void shouldCoerceToBigInts() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new IntegerLiteral(10), new LongLiteral(1234567890), new StringLiteral("\t -100 \t"), BIGINT_EXPRESSION, INT_EXPRESSION);
// When:
final Result result = CoercionUtil.coerceUserList(expressions, typeManager);
// Then:
assertThat(result.commonType(), is(Optional.of(SqlTypes.BIGINT)));
assertThat(result.expressions(), is(ImmutableList.of(new LongLiteral(10), new LongLiteral(1234567890), new LongLiteral(-100), BIGINT_EXPRESSION, cast(INT_EXPRESSION, SqlTypes.BIGINT))));
}
Aggregations