use of io.confluent.ksql.parser.tree.InsertValues 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.parser.tree.InsertValues in project ksql by confluentinc.
the class InsertValuesExecutorTest method shouldThrowIfColumnDoesNotExistInSchema.
@Test
public void shouldThrowIfColumnDoesNotExistInSchema() {
// Given:
givenSourceStreamWithSchema(SINGLE_VALUE_COLUMN_SCHEMA, SerdeFeatures.of(), SerdeFeatures.of());
final ConfiguredStatement<InsertValues> statement = givenInsertValues(ImmutableList.of(K0, ColumnName.of("NONEXISTENT")), ImmutableList.of(new StringLiteral("foo"), new StringLiteral("bar")));
// When:
final Exception e = assertThrows(KsqlException.class, () -> executor.execute(statement, mock(SessionProperties.class), engine, serviceContext));
// Then:
assertThat(e.getCause(), (hasMessage(containsString("Column name `NONEXISTENT` does not exist."))));
}
use of io.confluent.ksql.parser.tree.InsertValues 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.parser.tree.InsertValues 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.parser.tree.InsertValues 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"));
}
Aggregations