Skip to content

LogicalPlanner

Creating Instance

LogicalPlanner takes the following to be created:

LogicalPlanner is created when:

ImmutableAnalysis and RewrittenAnalysis

LogicalPlanner creates a RewrittenAnalysis with the following when created:

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

buildPersistentLogicalPlan

OutputNode buildPersistentLogicalPlan()

In summary, buildPersistentLogicalPlan creates an OutputNode for the RewrittenAnalysis (of a Query statement).


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 Query Logical Plan

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 builds an output node with a QueryProjectNode.

Building Source PlanNode

PlanNode buildSourceNode(
  boolean isWindowed)

buildSourceNode builds a non-join node when the RewrittenAnalysis is not of a join query.

Otherwise, buildSourceNode...FIXME


buildSourceNode is used when:

Creating DataSourceNode

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

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

Creating JoinNode

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

buildJoin creates a JoinNode.

Building Output Node

OutputNode buildOutputNode(
  PlanNode sourcePlanNode)

buildOutputNode creates one of the two possible OutputNodes:


buildOutputNode is used when: