use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class GenericExpressionResolverTest method shouldParseTimestamp.
@Test
public void shouldParseTimestamp() {
// Given:
final SqlType type = SqlTypes.TIMESTAMP;
final Expression exp = new StringLiteral("2021-01-09T04:40:02");
// When:
Object o = new GenericExpressionResolver(type, FIELD_NAME, registry, config, "insert value", false).resolve(exp);
// Then:
assertTrue(o instanceof Timestamp);
assertThat(((Timestamp) o).getTime(), is(1610167202000L));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class GenericExpressionResolverTest method shouldParseTime.
@Test
public void shouldParseTime() {
// Given:
final SqlType type = SqlTypes.TIME;
final Expression exp = new StringLiteral("04:40:02");
// When:
Object o = new GenericExpressionResolver(type, FIELD_NAME, registry, config, "insert value", false).resolve(exp);
// Then:
assertTrue(o instanceof Time);
assertThat(((Time) o).getTime(), is(16802000L));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldThrowIfTimestampColumnDoesNotExistForStream.
@Test
public void shouldThrowIfTimestampColumnDoesNotExistForStream() {
// Given:
givenProperty(CommonCreateConfigs.TIMESTAMP_NAME_PROPERTY, new StringLiteral("`will-not-find-me`"));
final CreateStream statement = new CreateStream(SOME_NAME, ONE_KEY_ONE_VALUE, false, true, withProperties, false);
// When:
final Exception e = assertThrows(KsqlException.class, () -> createSourceFactory.createStreamCommand(statement, ksqlConfig));
// Then:
assertThat(e.getMessage(), containsString("The TIMESTAMP column set in the WITH clause does not exist in the schema: " + "'will-not-find-me'"));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldBuildTimestampColumnForStream.
@Test
public void shouldBuildTimestampColumnForStream() {
// Given:
givenProperty(CommonCreateConfigs.TIMESTAMP_NAME_PROPERTY, new StringLiteral(quote(ELEMENT2.getName().text())));
final CreateStream statement = new CreateStream(SOME_NAME, STREAM_ELEMENTS, false, true, withProperties, false);
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getTimestampColumn(), is(Optional.of(new TimestampColumn(ELEMENT2.getName(), Optional.empty()))));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldHandleValueAvroSchemaNameForStream.
@Test
public void shouldHandleValueAvroSchemaNameForStream() {
// Given:
givenCommandFactoriesWithMocks();
givenProperty("VALUE_FORMAT", new StringLiteral("Avro"));
givenProperty("value_avro_schema_full_name", new StringLiteral("full.schema.name"));
final CreateStream statement = new CreateStream(SOME_NAME, ONE_KEY_ONE_VALUE, false, true, withProperties, false);
// When:
final CreateStreamCommand cmd = createSourceFactory.createStreamCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getFormats().getValueFormat(), is(FormatInfo.of(AVRO.name(), ImmutableMap.of(ConnectProperties.FULL_SCHEMA_NAME, "full.schema.name"))));
}
Aggregations