Search in sources :

Example 21 with BooleanLiteral

use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.

the class CreateSourceFactoryTest method shouldCreateStreamCommandWithSingleValueWrappingFromPropertiesNotConfig.

@Test
public void shouldCreateStreamCommandWithSingleValueWrappingFromPropertiesNotConfig() {
    // Given:
    ksqlConfig = new KsqlConfig(ImmutableMap.of(KsqlConfig.KSQL_WRAP_SINGLE_VALUES, true));
    final ImmutableMap<String, Object> overrides = ImmutableMap.of(KsqlConfig.KSQL_WRAP_SINGLE_VALUES, true);
    givenProperty(CommonCreateConfigs.WRAP_SINGLE_VALUE, new BooleanLiteral("false"));
    final CreateStream statement = new CreateStream(SOME_NAME, ONE_KEY_ONE_VALUE, false, true, withProperties, false);
    // When:
    final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig.cloneWithPropertyOverwrite(overrides));
    // Then:
    assertThat(cmd.getFormats().getValueFeatures(), is(SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES)));
}
Also used : CreateStreamCommand(io.confluent.ksql.execution.ddl.commands.CreateStreamCommand) BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) KsqlConfig(io.confluent.ksql.util.KsqlConfig) CreateStream(io.confluent.ksql.parser.tree.CreateStream) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 22 with BooleanLiteral

use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.

the class CreateSourceFactoryTest method shouldCreateTableCommandWithSingleValueWrappingFromPropertiesNotConfig.

@Test
public void shouldCreateTableCommandWithSingleValueWrappingFromPropertiesNotConfig() {
    // Given:
    ksqlConfig = new KsqlConfig(ImmutableMap.of(KsqlConfig.KSQL_WRAP_SINGLE_VALUES, true));
    final ImmutableMap<String, Object> overrides = ImmutableMap.of(KsqlConfig.KSQL_WRAP_SINGLE_VALUES, true);
    givenProperty(CommonCreateConfigs.WRAP_SINGLE_VALUE, new BooleanLiteral("false"));
    final CreateTable statement = new CreateTable(SOME_NAME, TABLE_ELEMENTS_1_VALUE, false, true, withProperties, false);
    // When:
    final CreateTableCommand cmd = createSourceFactory.createTableCommand(statement, ksqlConfig.cloneWithPropertyOverwrite(overrides));
    // Then:
    assertThat(cmd.getFormats().getValueFeatures(), is(SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES)));
}
Also used : BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) CreateTable(io.confluent.ksql.parser.tree.CreateTable) KsqlConfig(io.confluent.ksql.util.KsqlConfig) Matchers.containsString(org.hamcrest.Matchers.containsString) CreateTableCommand(io.confluent.ksql.execution.ddl.commands.CreateTableCommand) Test(org.junit.Test)

Aggregations

BooleanLiteral (io.confluent.ksql.execution.expression.tree.BooleanLiteral)22 Test (org.junit.Test)22 Expression (io.confluent.ksql.execution.expression.tree.Expression)14 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)12 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)11 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)11 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)11 KsqlException (io.confluent.ksql.util.KsqlException)11 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)9 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)6 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)4 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)4 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)3 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)3 Literal (io.confluent.ksql.execution.expression.tree.Literal)3 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)3 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)3 DecimalLiteral (io.confluent.ksql.execution.expression.tree.DecimalLiteral)2