use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class FeatureFlagCheckerTest method shouldThrowOnCreateStreamWithHeadersIfFeatureFlagIsDisabled.
@Test
public void shouldThrowOnCreateStreamWithHeadersIfFeatureFlagIsDisabled() {
// Given
final KsqlConfig config = new KsqlConfig(ImmutableMap.of(KsqlConfig.KSQL_HEADERS_COLUMNS_ENABLED, false));
final CreateStream createStream = new CreateStream(SourceName.of("stream1"), TableElements.of(new TableElement(ColumnName.of("col1"), new Type(SqlArray.of(SqlStruct.builder().field("KEY", SqlTypes.STRING).field("VALUE", SqlTypes.BYTES).build())), new ColumnConstraints.Builder().headers().build())), false, false, CreateSourceProperties.from(ImmutableMap.of(CommonCreateConfigs.KAFKA_TOPIC_NAME_PROPERTY, new StringLiteral("topic1"))), false);
final ConfiguredStatement configuredStatement = configured(config, createStream);
// When
final Exception e = assertThrows(KsqlException.class, () -> FeatureFlagChecker.throwOnDisabledFeatures(configuredStatement));
// Then
assertThat(e.getMessage(), containsString("Cannot create Stream because schema with headers columns is disabled."));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class FeatureFlagCheckerTest method configured.
private ConfiguredStatement configured(final KsqlConfig config, final Statement statement) {
final ConfiguredStatement mockConfigured = mock(ConfiguredStatement.class);
when(mockConfigured.getStatement()).thenReturn(statement);
when(mockConfigured.getSessionConfig()).thenReturn(SessionConfig.of(config, ImmutableMap.of()));
return mockConfigured;
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class DefaultSchemaInjector method buildElements.
private static TableElements buildElements(final ConfiguredStatement<CreateSource> preparedStatement, final Optional<SchemaAndId> keySchema, final Optional<SchemaAndId> valueSchema) {
final List<TableElement> elements = new ArrayList<>();
if (keySchema.isPresent()) {
final ColumnConstraints constraints = getKeyConstraints(preparedStatement.getStatement());
keySchema.get().columns.stream().map(col -> new TableElement(col.name(), new Type(col.type()), constraints)).forEach(elements::add);
} else {
getKeyColumns(preparedStatement).forEach(elements::add);
}
if (valueSchema.isPresent()) {
valueSchema.get().columns.stream().map(col -> new TableElement(col.name(), new Type(col.type()))).forEach(elements::add);
} else {
getValueColumns(preparedStatement).forEach(elements::add);
}
return TableElements.of(elements);
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ListPropertiesExecutorTest method shouldContainLevelField.
@Test
public void shouldContainLevelField() {
// When:
final PropertiesList properties = (PropertiesList) CUSTOM_EXECUTORS.listProperties().execute((ConfiguredStatement<ListProperties>) engine.configure("LIST PROPERTIES;"), mock(SessionProperties.class), engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(toMap(properties).get(KsqlConfig.KSQL_EXT_DIR).getLevel(), equalTo("SERVER"));
assertThat(toMap(properties).get(KsqlConfig.KSQL_QUERY_ERROR_MAX_QUEUE_SIZE).getLevel(), equalTo("QUERY"));
}
use of io.confluent.ksql.statement.ConfiguredStatement in project ksql by confluentinc.
the class ListPropertiesExecutorTest method shouldContainAllowField.
@Test
public void shouldContainAllowField() {
// When:
final PropertiesList properties = (PropertiesList) CUSTOM_EXECUTORS.listProperties().execute((ConfiguredStatement<ListProperties>) engine.configure("LIST PROPERTIES;"), mock(SessionProperties.class), engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(toMap(properties).get("ksql.streams.commit.interval.ms").getEditable(), equalTo(true));
assertThat(toMap(properties).get(KsqlConfig.KSQL_PERSISTENT_QUERY_NAME_PREFIX_CONFIG).getEditable(), equalTo(false));
}
Aggregations