Search in sources :

Example 1 with KsqlBareOutputNode

use of io.confluent.ksql.planner.plan.KsqlBareOutputNode in project ksql by confluentinc.

the class PhysicalPlanBuilder method buildPhysicalPlan.

public QueryMetadata buildPhysicalPlan(final Pair<String, PlanNode> statementPlanPair) throws Exception {
    final SchemaKStream resultStream = statementPlanPair.getRight().buildStream(builder, ksqlConfig, kafkaTopicClient, functionRegistry, overriddenStreamsProperties, schemaRegistryClient);
    final OutputNode outputNode = resultStream.outputNode();
    boolean isBareQuery = outputNode instanceof KsqlBareOutputNode;
    // the corresponding Kafka Streams job
    if (isBareQuery && !(resultStream instanceof QueuedSchemaKStream)) {
        throw new Exception(String.format("Mismatch between logical and physical output; " + "expected a QueuedSchemaKStream based on logical " + "KsqlBareOutputNode, found a %s instead", resultStream.getClass().getCanonicalName()));
    }
    String serviceId = getServiceId();
    String persistanceQueryPrefix = ksqlConfig.get(KsqlConfig.KSQL_PERSISTENT_QUERY_NAME_PREFIX_CONFIG).toString();
    String transientQueryPrefix = ksqlConfig.get(KsqlConfig.KSQL_TRANSIENT_QUERY_NAME_PREFIX_CONFIG).toString();
    if (isBareQuery) {
        return buildPlanForBareQuery((QueuedSchemaKStream) resultStream, (KsqlBareOutputNode) outputNode, serviceId, transientQueryPrefix, statementPlanPair.getLeft());
    } else if (outputNode instanceof KsqlStructuredDataOutputNode) {
        return buildPlanForStructuredOutputNode(statementPlanPair.getLeft(), resultStream, (KsqlStructuredDataOutputNode) outputNode, serviceId, persistanceQueryPrefix, statementPlanPair.getLeft());
    } else {
        throw new KsqlException("Sink data source of type: " + outputNode.getClass() + " is not supported.");
    }
}
Also used : KsqlBareOutputNode(io.confluent.ksql.planner.plan.KsqlBareOutputNode) KsqlStructuredDataOutputNode(io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode) OutputNode(io.confluent.ksql.planner.plan.OutputNode) KsqlBareOutputNode(io.confluent.ksql.planner.plan.KsqlBareOutputNode) SchemaKStream(io.confluent.ksql.structured.SchemaKStream) QueuedSchemaKStream(io.confluent.ksql.structured.QueuedSchemaKStream) KsqlStructuredDataOutputNode(io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode) QueuedSchemaKStream(io.confluent.ksql.structured.QueuedSchemaKStream) KsqlException(io.confluent.ksql.util.KsqlException) KsqlException(io.confluent.ksql.util.KsqlException)

Aggregations

KsqlBareOutputNode (io.confluent.ksql.planner.plan.KsqlBareOutputNode)1 KsqlStructuredDataOutputNode (io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode)1 OutputNode (io.confluent.ksql.planner.plan.OutputNode)1 QueuedSchemaKStream (io.confluent.ksql.structured.QueuedSchemaKStream)1 SchemaKStream (io.confluent.ksql.structured.SchemaKStream)1 KsqlException (io.confluent.ksql.util.KsqlException)1