use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class CreateSourceAsPropertiesTest method shouldSetKeyFullSchemaName.
@Test
public void shouldSetKeyFullSchemaName() {
// Given:
final CreateSourceAsProperties props = CreateSourceAsProperties.from(ImmutableMap.<String, Literal>builder().put(FORMAT_PROPERTY, new StringLiteral("Json_sr")).put(KEY_SCHEMA_FULL_NAME, new StringLiteral("KeySchema")).build());
// Then:
assertThat(props.getKeyFormatProperties("json_sr", "foo"), hasEntry(ConnectProperties.FULL_SCHEMA_NAME, "KeySchema"));
}
use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class CreateSourceAsPropertiesTest method shouldSetValueFullSchemaName.
@Test
public void shouldSetValueFullSchemaName() {
// When:
final CreateSourceAsProperties properties = CreateSourceAsProperties.from(ImmutableMap.<String, Literal>builder().put(CommonCreateConfigs.VALUE_FORMAT_PROPERTY, new StringLiteral("Protobuf")).put(CommonCreateConfigs.VALUE_SCHEMA_FULL_NAME, new StringLiteral("schema")).build());
// Then:
assertThat(properties.getValueFormatProperties(), hasEntry(ConnectProperties.FULL_SCHEMA_NAME, "schema"));
}
use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class DefaultSchemaInjectorTest method givenFormatsAndProps.
private void givenFormatsAndProps(final String keyFormat, final String valueFormat, final Map<String, Literal> additionalProps) {
final HashMap<String, Literal> props = new HashMap<>(BASE_PROPS);
if (keyFormat != null) {
props.put("KEY_FORMAT", new StringLiteral(keyFormat));
}
if (valueFormat != null) {
props.put("VALUE_FORMAT", new StringLiteral(valueFormat));
}
props.putAll(additionalProps);
final CreateSourceProperties csProps = CreateSourceProperties.from(props);
final CreateSourceAsProperties casProps = CreateSourceAsProperties.from(props);
when(cs.getProperties()).thenReturn(csProps);
when(ct.getProperties()).thenReturn(csProps);
when(csas.getProperties()).thenReturn(casProps);
when(ctas.getProperties()).thenReturn(casProps);
/*
when(csas.getSink()).thenReturn(
Sink.of(SourceName.of("csas"), true, false, casProps));
when(ctas.getSink()).thenReturn(
Sink.of(SourceName.of("ctas"), true, false, casProps));
*/
}
use of io.confluent.ksql.execution.expression.tree.Literal in project ksql by confluentinc.
the class ImplicitlyCastResolverTest method shouldNotCastToDecimal.
@Test
public void shouldNotCastToDecimal() {
// Given
final List<Literal> fromLiterals = Arrays.asList(new BooleanLiteral("true"), new StringLiteral("10.2"), new DecimalLiteral(BigDecimal.valueOf(10.133)));
for (final Literal literal : fromLiterals) {
// When
final Expression expression = ImplicitlyCastResolver.resolve(literal, DECIMAL_5_2);
// Then
assertThat("Should not cast " + literal.getClass().getSimpleName() + " to " + DECIMAL_5_2, expression, instanceOf(literal.getClass()));
assertThat("Should not cast " + literal.getClass().getSimpleName() + " to " + DECIMAL_5_2, expression.equals(literal), is(true));
}
}
Aggregations