Search in sources :

Example 6 with WindowInfo

use of io.confluent.ksql.serde.WindowInfo in project ksql by confluentinc.

the class SchemaKSourceFactory method buildWindowedTable.

private static SchemaKTable<?> buildWindowedTable(final PlanBuildContext buildContext, final DataSource dataSource, final Stacker contextStacker) {
    final WindowInfo windowInfo = dataSource.getKsqlTopic().getKeyFormat().getWindowInfo().orElseThrow(IllegalArgumentException::new);
    final int pseudoColumnVersionToUse = determinePseudoColumnVersionToUse(buildContext);
    final SourceStep<KTableHolder<Windowed<GenericKey>>> step = ExecutionStepFactory.tableSourceWindowed(contextStacker, dataSource.getSchema(), dataSource.getKafkaTopicName(), Formats.from(dataSource.getKsqlTopic()), windowInfo, dataSource.getTimestampColumn(), pseudoColumnVersionToUse);
    return schemaKTable(buildContext, resolveSchema(buildContext, step, dataSource), dataSource.getKsqlTopic().getKeyFormat(), step);
}
Also used : KTableHolder(io.confluent.ksql.execution.plan.KTableHolder) GenericKey(io.confluent.ksql.GenericKey) WindowInfo(io.confluent.ksql.serde.WindowInfo)

Example 7 with WindowInfo

use of io.confluent.ksql.serde.WindowInfo in project ksql by confluentinc.

the class KsMaterialization method windowed.

// Enforced by type
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Override
public StreamsMaterializedWindowedTable windowed() {
    if (!windowInfo.isPresent()) {
        throw new UnsupportedOperationException("Table has non-windowed key");
    }
    final WindowInfo wndInfo = windowInfo.get();
    final WindowType wndType = wndInfo.getType();
    switch(wndType) {
        case SESSION:
            if (stateStore.getKsqlConfig().getBoolean(KsqlConfig.KSQL_QUERY_PULL_CONSISTENCY_OFFSET_VECTOR_ENABLED)) {
                return new KsMaterializedSessionTableIQv2(stateStore);
            } else {
                return new KsMaterializedSessionTable(stateStore, SessionStoreCacheBypass::fetch, SessionStoreCacheBypass::fetchRange);
            }
        case HOPPING:
        case TUMBLING:
            if (stateStore.getKsqlConfig().getBoolean(KsqlConfig.KSQL_QUERY_PULL_CONSISTENCY_OFFSET_VECTOR_ENABLED)) {
                return new KsMaterializedWindowTableIQv2(stateStore, wndInfo.getSize().get());
            } else {
                return new KsMaterializedWindowTable(stateStore, wndInfo.getSize().get(), WindowStoreCacheBypass::fetch, WindowStoreCacheBypass::fetchAll, WindowStoreCacheBypass::fetchRange);
            }
        default:
            throw new UnsupportedOperationException("Unknown window type: " + wndInfo);
    }
}
Also used : WindowType(io.confluent.ksql.model.WindowType) WindowInfo(io.confluent.ksql.serde.WindowInfo)

Aggregations

WindowInfo (io.confluent.ksql.serde.WindowInfo)7 GenericRow (io.confluent.ksql.GenericRow)2 KsqlTopic (io.confluent.ksql.execution.ddl.commands.KsqlTopic)2 KStreamHolder (io.confluent.ksql.execution.plan.KStreamHolder)2 SourceBuilderUtils.getPhysicalSchema (io.confluent.ksql.execution.streams.SourceBuilderUtils.getPhysicalSchema)2 WindowType (io.confluent.ksql.model.WindowType)2 PhysicalSchema (io.confluent.ksql.schema.ksql.PhysicalSchema)2 GenericKey (io.confluent.ksql.GenericKey)1 StatementRewriteForMagicPseudoTimestamp (io.confluent.ksql.engine.rewrite.StatementRewriteForMagicPseudoTimestamp)1 QueryContext (io.confluent.ksql.execution.context.QueryContext)1 Stacker (io.confluent.ksql.execution.context.QueryContext.Stacker)1 Expression (io.confluent.ksql.execution.expression.tree.Expression)1 FunctionCall (io.confluent.ksql.execution.expression.tree.FunctionCall)1 ExecutionStep (io.confluent.ksql.execution.plan.ExecutionStep)1 Formats (io.confluent.ksql.execution.plan.Formats)1 JoinType (io.confluent.ksql.execution.plan.JoinType)1 KTableHolder (io.confluent.ksql.execution.plan.KTableHolder)1 SelectExpression (io.confluent.ksql.execution.plan.SelectExpression)1 StreamFilter (io.confluent.ksql.execution.plan.StreamFilter)1 StreamFlatMap (io.confluent.ksql.execution.plan.StreamFlatMap)1