Table of Contents

Calcite (Farrago, Optiq)

About

Calcite is a Java SQL Processing engine where the data storage is developed in plugin.

Calcite is an open source cost based query optimizer and query execution framework.

Getting Started

Component

Key Concept

Relational Algebra

Row Expression

List:

Rules

Rules - RelOptRule (Interface) used to modified query plan

Documentation / Reference

https://www.slideshare.net/JordanHalterman/introduction-to-apache-calcite

Query to relational Operator

Every query is represented as a tree of relational operators.

You can:

Schema

Schemas are defined as a list of tables, each containing minimally a table name and a url.

Jdbc

jdbc:calcite:model=target/test-classes/model.json
// or
jdbc:calcite:schemaFactory=org.apache.calcite.adapter.druid.DruidSchemaFactory;schema.url=http://localhost:8082;schema.coordinatorUrl=http://localhost:8081
{
  "version": "1.0",
  "defaultSchema": "SALES",
  "schemas": [
    {
      "name": "SALES",
      "type": "custom",
      "factory": "org.apache.calcite.adapter.csv.CsvSchemaFactory",
      "operand": {
        "directory": "sales"
      }
    }
  ]
}

where:

Adapter can be built programmatically using the Schema SPI. see Calcite Schema SPI

DDL

SELECT and DML are standardized, but DDL tends to be database-specific, so the calcite policy is that DDL extensions are made outside of Calcite. See CALCITE-609 for example.

You could copy work that has already been done in Drill and Phoenix in extending Calcite’s core parser for DDL.

Test

VM:

Dataset: Database - HyperSQL DataBase (HSQLDB)

Planner

Build

Stream

Documentation / Reference