use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldGetKeyAndValueFormatFromFormat.
@Test
public void shouldGetKeyAndValueFormatFromFormat() {
// Given:
final CreateSourceProperties props = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(KEY_FORMAT_PROPERTY, new StringLiteral("KAFKA")).put(VALUE_FORMAT_PROPERTY, new StringLiteral("AVRO")).build());
// When / Then:
assertThat(props.getKeyFormat(SourceName.of("foo")).get().getFormat(), is("KAFKA"));
assertThat(props.getValueFormat().get().getFormat(), is("AVRO"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldThrowIfValueSchemaNameAndAvroSchemaNameProvided.
@Test
public void shouldThrowIfValueSchemaNameAndAvroSchemaNameProvided() {
// When:
final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(VALUE_SCHEMA_FULL_NAME, new StringLiteral("value_schema")).put(VALUE_AVRO_SCHEMA_FULL_NAME, new StringLiteral("value_schema")).build()));
// Then:
assertThat(e.getMessage(), is("Cannot supply both 'VALUE_AVRO_SCHEMA_FULL_NAME' " + "and 'VALUE_SCHEMA_FULL_NAME' properties. Please only set 'VALUE_SCHEMA_FULL_NAME'."));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourcePropertiesTest method shouldThrowOnHoppingWindowWithOutSize.
@Test
public void shouldThrowOnHoppingWindowWithOutSize() {
// When:
final Exception e = assertThrows(KsqlException.class, () -> CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(WINDOW_TYPE_PROPERTY, new StringLiteral("hopping")).build()));
// Then:
assertThat(e.getMessage(), containsString("HOPPING windows require 'WINDOW_SIZE' to be provided in the WITH clause. " + "For example: 'WINDOW_SIZE'='10 SECONDS'"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral 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.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class DefaultFormatInjectorTest method shouldThrowIfMissingDefaultValueFormatConfig.
@Test
public void shouldThrowIfMissingDefaultValueFormatConfig() {
// Given
givenConfig(ImmutableMap.of());
givenSourceProps(ImmutableMap.of("KEY_FORMAT", new StringLiteral("KAFKA")));
// Expect / When
final Exception e = assertThrows(KsqlStatementException.class, () -> injector.inject(csStatement));
// Then
assertThat(e.getMessage(), containsString("Statement is missing the 'VALUE_FORMAT' property from the WITH clause."));
assertThat(e.getMessage(), containsString("Either provide one or set a default via the '" + KsqlConfig.KSQL_DEFAULT_VALUE_FORMAT_CONFIG + "' config."));
}
Aggregations