Search in sources :

Example 91 with StringLiteral

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"));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) Test(org.junit.Test)

Example 92 with StringLiteral

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'."));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Literal(io.confluent.ksql.execution.expression.tree.Literal) BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) Matchers.containsString(org.hamcrest.Matchers.containsString) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 93 with StringLiteral

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'"));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 94 with StringLiteral

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."));
}
Also used : ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) Type(io.confluent.ksql.execution.expression.tree.Type) StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) ColumnConstraints(io.confluent.ksql.parser.tree.ColumnConstraints) KsqlConfig(io.confluent.ksql.util.KsqlConfig) CreateStream(io.confluent.ksql.parser.tree.CreateStream) TableElement(io.confluent.ksql.parser.tree.TableElement) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 95 with StringLiteral

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."));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) KsqlStatementException(io.confluent.ksql.util.KsqlStatementException) Test(org.junit.Test)

Aggregations

StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)204 Test (org.junit.Test)199 Expression (io.confluent.ksql.execution.expression.tree.Expression)95 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)70 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)66 KsqlException (io.confluent.ksql.util.KsqlException)64 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)63 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)63 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)63 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)61 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)53 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)51 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)49 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)43 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)36 LongLiteral (io.confluent.ksql.execution.expression.tree.LongLiteral)35 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)34 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)31 BooleanLiteral (io.confluent.ksql.execution.expression.tree.BooleanLiteral)28 Matchers.containsString (org.hamcrest.Matchers.containsString)27