Calcite - Logical Plan (Logical algebra)

Card Puncher Data Processing


Sql Engine - Logical Plan (Query) in Calcite

A logical plan is a relational expression with only logical operator. Logical algebra has no implementation of the relational operator and therefore can't run.

The logical plan is the first plan created when transforming a Sql tree into relational algebra.

All logical operator starts with the prefix Logical



Every logical plan is created from a SQL tree (sqlNode)

The main entry point is the sqltorelconverter but you would generally use a tool to call it such as the planner

not the same that the planner optimizer)


Extract from the getting started page with the query processing tool

RelRoot relRoot = planner.rel(sqlNodeValidated);


With the sqlToRelConverter apache/calcite/blob/master/core/src/main/java/org/apache/calcite/prepare/

RelRoot root = sqlToRelConverter.convertQuery(sqlQuery, needsValidation, true);


As a logical plan is just a relational expression, you just need to print it (explain):

Example: All logical operator starts with the prefix Logical

  3:LogicalFilter(condition=[=($0, 100)])
    2:LogicalJoin(condition=[=($1, $5)], joinType=[inner])
      0:LogicalTableScan(table=[[HR, emps]])
      1:LogicalTableScan(table=[[HR, depts]])

This is equivalent to the below SQL:

select * 
from emps inner join depts on deptno
where empid = 100

Discover More
Card Puncher Data Processing
Calcite - Getting Started (from Sql to Resultset)

A getting started page that shows a query planning process (ie from sql to resultset process) gerardnico/calcite/blob/master/src/test/java/com/gerardnico/calcite/
Card Puncher Data Processing
Calcite - Physical Plan

in calcite. The physical plan is the relation algebra expression that describe how to perform the operation on the data. It's the output of the optimizer Example of output of a physical_plan (There...
Card Puncher Data Processing
Calcite - Query Planning Process (Sql Processing)

in Calcite The query planning process is the entire process that takes a SQL to a result. The process can be resumed as follow: Phase 1: The Sql statement (Query) is parsed to build a parse tree...
Card Puncher Data Processing
Calcite - Relational Expression (RelNode, Algebra)

Relational Algebra in Calcite A relational expression is represented by a tree of RelNode. A RelNode can be considered as the same logic than the Spark dataframe. TableScan Project Filter...

Share this page:
Follow us:
Task Runner