use of io.confluent.ksql.execution.timestamp.TimestampColumn in project ksql by confluentinc.
the class CreateSourceFactoryTest method shouldBuildTimestampColumnForTable.
@Test
public void shouldBuildTimestampColumnForTable() {
// Given:
givenProperty(CommonCreateConfigs.TIMESTAMP_NAME_PROPERTY, new StringLiteral(quote(ELEMENT2.getName().text())));
final CreateTable statement = new CreateTable(SOME_NAME, TABLE_ELEMENTS, false, true, withProperties, false);
// When:
final CreateTableCommand cmd = createSourceFactory.createTableCommand(statement, ksqlConfig);
// Then:
assertThat(cmd.getTimestampColumn(), is(Optional.of(new TimestampColumn(ELEMENT2.getName(), Optional.empty()))));
}
use of io.confluent.ksql.execution.timestamp.TimestampColumn in project ksql by confluentinc.
the class CreateSourceFactory method buildTimestampColumn.
private static Optional<TimestampColumn> buildTimestampColumn(final KsqlConfig ksqlConfig, final CreateSourceProperties properties, final LogicalSchema schema) {
final Optional<ColumnName> timestampName = properties.getTimestampColumnName();
final Optional<TimestampColumn> timestampColumn = timestampName.map(n -> new TimestampColumn(n, properties.getTimestampFormat()));
// create the final extraction policy to validate that the ref/format are OK
TimestampExtractionPolicyFactory.validateTimestampColumn(ksqlConfig, schema, timestampColumn);
return timestampColumn;
}
use of io.confluent.ksql.execution.timestamp.TimestampColumn in project ksql by confluentinc.
the class LogicalPlanner method buildOutputNode.
private OutputNode buildOutputNode(final PlanNode sourcePlanNode) {
final LogicalSchema inputSchema = sourcePlanNode.getSchema();
final Optional<TimestampColumn> timestampColumn = getTimestampColumn(inputSchema, analysis);
if (!analysis.getInto().isPresent()) {
return new KsqlBareOutputNode(new PlanNodeId("KSQL_STDOUT_NAME"), sourcePlanNode, inputSchema, analysis.getLimitClause(), timestampColumn, getWindowInfo());
}
final Into into = analysis.getInto().get();
final KsqlTopic existingTopic = getSinkTopic(into, sourcePlanNode.getSchema());
return new KsqlStructuredDataOutputNode(new PlanNodeId(into.getName().text()), sourcePlanNode, inputSchema, timestampColumn, existingTopic, analysis.getLimitClause(), into.isCreate(), into.getName(), analysis.getOrReplace());
}
use of io.confluent.ksql.execution.timestamp.TimestampColumn in project ksql by confluentinc.
the class SourceBuilderUtils method timestampExtractor.
static TimestampExtractor timestampExtractor(final KsqlConfig ksqlConfig, final LogicalSchema sourceSchema, final Optional<TimestampColumn> timestampColumn, final SourceStep<?> streamSource, final RuntimeBuildContext buildContext) {
final TimestampExtractionPolicy timestampPolicy = TimestampExtractionPolicyFactory.create(ksqlConfig, sourceSchema, timestampColumn);
final Optional<Column> tsColumn = timestampColumn.map(TimestampColumn::getColumn).map(c -> sourceSchema.findColumn(c).orElseThrow(IllegalStateException::new));
final QueryContext queryContext = streamSource.getProperties().getQueryContext();
return timestampPolicy.create(tsColumn, ksqlConfig.getBoolean(KsqlConfig.KSQL_TIMESTAMP_THROW_ON_INVALID), buildContext.getProcessingLogger(queryContext));
}
use of io.confluent.ksql.execution.timestamp.TimestampColumn in project ksql by confluentinc.
the class SinkBuilderTest method shouldBuildStreamUsingTransformTimestampWhenTimestampIsSpecified.
@Test
public void shouldBuildStreamUsingTransformTimestampWhenTimestampIsSpecified() {
// When
SinkBuilder.build(SCHEMA, Formats.of(KEY_FORMAT, VALUE_FORMAT, SerdeFeatures.of(), SerdeFeatures.of()), Optional.of(new TimestampColumn(ColumnName.of("BLUE"), Optional.empty())), TOPIC, kStream, executionKeyFactory, queryContext, buildContext);
// Then
final InOrder inOrder = Mockito.inOrder(kStream);
inOrder.verify(kStream).transform(any(), any(Named.class));
inOrder.verify(kStream).to(eq(TOPIC), any());
inOrder.verifyNoMoreInteractions();
}
Aggregations