Skip to content

LogicalPlanner

Creating Instance

LogicalPlanner takes the following to be created:

LogicalPlanner is created when:

ImmutableAnalysis and RewrittenAnalysis

LogicalPlanner creates a RewrittenAnalysis for the given ImmutableAnalysis when created.

The RewrittenAnalysis is used when LogicalPlanner is requested for the following:

buildPersistentLogicalPlan

OutputNode buildPersistentLogicalPlan()

buildPersistentLogicalPlan creates an OutputNode.

buildPersistentLogicalPlan is used when:

Step 1. Source Node

buildPersistentLogicalPlan builds a source node (with isWindowed flag based on the RewrittenAnalysis of the query).

Step 2. FilterNode

For a query with WHERE clause (per the RewrittenAnalysis), buildPersistentLogicalPlan creates a new QueryFilterNode to be the current PlanNode.

Step 3. UserRepartitionNode

For a query with PartitionBy clause (per the RewrittenAnalysis), buildPersistentLogicalPlan buildUserRepartitionNode.

Step 4. FlatMapNode

For a query with TableFunctions (per the RewrittenAnalysis), buildPersistentLogicalPlan buildFlatMapNode.

Building FlatMapNode

FlatMapNode buildFlatMapNode(
  PlanNode sourcePlanNode)

buildFlatMapNode creates a FlatMapNode (with a PlanNodeId with FlatMap ID).

AggregateNode

For a query with GroupBy clause (per the RewrittenAnalysis), buildPersistentLogicalPlan buildAggregateNode. Otherwise, buildPersistentLogicalPlan...FIXME

RefinementInfo

For a query with a RefinementInfo (per the RewrittenAnalysis), buildPersistentLogicalPlan...FIXME

OutputNode

In the end, buildPersistentLogicalPlan builds an output node.

Building Logical Plan of Query (buildQueryLogicalPlan)

OutputNode buildQueryLogicalPlan(
  QueryPlannerOptions queryPlannerOptions,
  boolean isScalablePush)

buildQueryLogicalPlan is used when:

Step 1. Source Node

buildQueryLogicalPlan builds a source node (with isWindowed flag based on the RewrittenAnalysis of the query).

Step 2. Filter Node

For a query with WHERE clause (per the RewrittenAnalysis), buildQueryLogicalPlan creates a new QueryFilterNode to be the current PlanNode. Otherwise, buildQueryLogicalPlan throws a KsqlException for a missing WHERE clause unless getTableScansEnabled is enabled.

Step 3. Limit Node

For a non-isScalablePush query with LIMIT clause, buildQueryLogicalPlan builds a limit PlanNode to be the current PlanNode.

Step 4. Project Node

In the end, buildQueryLogicalPlan creates a QueryProjectNode (to be the current PlanNode) and builds an output node.

Building DataSourceNode or JoinNode (buildSourceNode)

PlanNode buildSourceNode(
  boolean isWindowed)

buildSourceNode buildNonJoinNode when the RewrittenAnalysis is not for a join.

Otherwise, buildSourceNode...FIXME

buildSourceNode is used when:

Creating DataSourceNode (buildNonJoinNode)

DataSourceNode buildNonJoinNode(
  AliasedDataSource dataSource,
  boolean isWindowed,
  KsqlConfig ksqlConfig)

buildNonJoinNode creates a DataSourceNode (with a new PlanNodeId with KsqlTopic ID).

Creating JoinNode (buildJoin)

JoinNode buildJoin(
  Join root,
  String prefix,
  boolean isWindowed)

buildJoin creates a JoinNode.

Building Output Node

OutputNode buildOutputNode(
  PlanNode sourcePlanNode)

buildOutputNode creates a KsqlStructuredDataOutputNode or a KsqlBareOutputNode based on whether this is a QueryContainer or not (with a Sink to write into defined or not), respectively.

buildOutputNode is used when:

Back to top