Search in sources :

Example 6 with Literal

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

the class CreateSourceProperties method withFormats.

public CreateSourceProperties withFormats(final String keyFormat, final String valueFormat) {
    final Map<String, Literal> originals = props.copyOfOriginalLiterals();
    originals.put(CommonCreateConfigs.KEY_FORMAT_PROPERTY, new StringLiteral(keyFormat));
    originals.put(CommonCreateConfigs.VALUE_FORMAT_PROPERTY, new StringLiteral(valueFormat));
    return new CreateSourceProperties(originals, durationParser);
}
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)

Example 7 with Literal

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

the class CreateSourcePropertiesTest method shouldNotQuoteNonStringPropValues.

@Test
public void shouldNotQuoteNonStringPropValues() {
    // Given:
    final CreateSourceProperties props = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put("Wrap_Single_value", new BooleanLiteral("true")).build());
    // When:
    final String sql = props.toString();
    // Then:
    assertThat(sql, containsString("WRAP_SINGLE_VALUE=true"));
}
Also used : BooleanLiteral(io.confluent.ksql.execution.expression.tree.BooleanLiteral) 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) Test(org.junit.Test)

Example 8 with Literal

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

the class CreateSourcePropertiesTest method shouldSetPartitions.

@Test
public void shouldSetPartitions() {
    // When:
    final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.SOURCE_NUMBER_OF_PARTITIONS, new IntegerLiteral(2)).build());
    // Then:
    assertThat(properties.getPartitions(), is(Optional.of(2)));
}
Also used : 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) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Test(org.junit.Test)

Example 9 with Literal

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

the class CreateSourcePropertiesTest method shouldGetKeyAndValueSchemaIdFromFormat.

@Test
public void shouldGetKeyAndValueSchemaIdFromFormat() {
    // Given:
    final CreateSourceProperties props = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(FORMAT_PROPERTY, new StringLiteral("AVRO")).put(KEY_SCHEMA_ID, new IntegerLiteral(123)).put(VALUE_SCHEMA_ID, new IntegerLiteral(456)).build());
    // When / Then:
    assertThat(props.getKeyFormat(SourceName.of("foo")).get().getProperties(), hasEntry(ConnectProperties.SCHEMA_ID, "123"));
    assertThat(props.getValueFormat().get().getProperties(), hasEntry(ConnectProperties.SCHEMA_ID, "456"));
}
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) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Test(org.junit.Test)

Example 10 with Literal

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

the class CreateSourcePropertiesTest method shouldHandleNonUpperCasePropNames.

@Test
public void shouldHandleNonUpperCasePropNames() {
    // When:
    final CreateSourceProperties properties = CreateSourceProperties.from(ImmutableMap.<String, Literal>builder().putAll(MINIMUM_VALID_PROPS).put(CommonCreateConfigs.WRAP_SINGLE_VALUE.toLowerCase(), new StringLiteral("false")).build());
    // Then:
    assertThat(properties.getValueSerdeFeatures(), is(SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES)));
}
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) Test(org.junit.Test)

Aggregations

Literal (io.confluent.ksql.execution.expression.tree.Literal)39 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)38 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)32 Test (org.junit.Test)32 BooleanLiteral (io.confluent.ksql.execution.expression.tree.BooleanLiteral)28 Matchers.containsString (org.hamcrest.Matchers.containsString)27 KsqlException (io.confluent.ksql.util.KsqlException)10 ImmutableMap (com.google.common.collect.ImmutableMap)8 CreateSourceProperties (io.confluent.ksql.parser.properties.with.CreateSourceProperties)6 StringContains.containsString (org.hamcrest.core.StringContains.containsString)5 HashMap (java.util.HashMap)4 EqualsTester (com.google.common.testing.EqualsTester)3 DecimalLiteral (io.confluent.ksql.execution.expression.tree.DecimalLiteral)3 DoubleLiteral (io.confluent.ksql.execution.expression.tree.DoubleLiteral)3 Expression (io.confluent.ksql.execution.expression.tree.Expression)3 LongLiteral (io.confluent.ksql.execution.expression.tree.LongLiteral)3 CreateTable (io.confluent.ksql.parser.tree.CreateTable)3 ImmutableMap.of (com.google.common.collect.ImmutableMap.of)2 WindowType (io.confluent.ksql.model.WindowType)2 ColumnName (io.confluent.ksql.name.ColumnName)2