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);
}
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"));
}
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)));
}
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"));
}
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)));
}
Aggregations