layout: docs title: Adapters permalink: /docs/adapter.html

Schema adapters

A schema adapter allows Calcite to read particular kind of data, presenting the data as tables within a schema.

  • Cassandra adapter (calcite-cassandra)
  • CSV adapter (example/csv)
  • Druid adapter (calcite-druid)
  • Elasticsearch adapter (calcite-elasticsearch)
  • File adapter (calcite-file)
  • JDBC adapter (part of calcite-core)
  • MongoDB adapter (calcite-mongodb)
  • Pig adapter (calcite-pig)
  • Solr cloud adapter (solr-sql)
  • Spark adapter (calcite-spark)
  • Splunk adapter (calcite-splunk)
  • Eclipse Memory Analyzer (MAT) adapter (mat-calcite-plugin)

Other language interfaces

  • Piglet (calcite-piglet) runs queries in a subset of Pig Latin

Engines

Many projects and products use Apache Calcite for SQL parsing, query optimization, data virtualization/federation, and materialized view rewrite. Some of them are listed on the [“powered by Calcite”]({{ site.baseurl }}/docs/powered_by.html) page.

Drivers

A driver allows you to connect to Calcite from your application.

  • JDBC driver

The JDBC driver is powered by [Avatica]({{ site.avaticaBaseurl }}/docs/). Connections can be local or remote (JSON over HTTP or Protobuf over HTTP).

The basic form of the JDBC connect string is

jdbc:calcite:property=value;property2=value2

where property, property2 are properties as described below. (Connect strings are compliant with OLE DB Connect String syntax, as implemented by Avatica's ConnectStringParser.)

JDBC connect string parameters

PropertyDescription
approximateDecimalWhether approximate results from aggregate functions on DECIMAL types are acceptable
approximateDistinctCountWhether approximate results from COUNT(DISTINCT ...) aggregate functions are acceptable
approximateTopNWhether approximate results from “Top N” queries * (ORDER BY aggFun() DESC LIMIT n) are acceptable
caseSensitiveWhether identifiers are matched case-sensitively. If not specified, value from lex is used.
conformanceSQL conformance level. Values: DEFAULT (the default, similar to PRAGMATIC_2003), ORACLE_10, ORACLE_12, PRAGMATIC_99, PRAGMATIC_2003, STRICT_92, STRICT_99, STRICT_2003, SQL_SERVER_2008.
createMaterializationsWhether Calcite should create materializations. Default false.
defaultNullCollationHow NULL values should be sorted if neither NULLS FIRST nor NULLS LAST are specified in a query. The default, HIGH, sorts NULL values the same as Oracle.
druidFetchHow many rows the Druid adapter should fetch at a time when executing SELECT queries.
forceDecorrelateWhether the planner should try de-correlating as much as possible. Default true.
funCollection of built-in functions and operators. Valid values: “standard” (the default), “oracle”.
lexLexical policy. Values are ORACLE (default), MYSQL, MYSQL_ANSI, SQL_SERVER, JAVA.
materializationsEnabledWhether Calcite should use materializations. Default false.
modelURI of the JSON model file.
parserFactoryParser factory. The name of a class that implements SqlParserImplFactory and has a public default constructor or an INSTANCE constant.
quotingHow identifiers are quoted. Values are DOUBLE_QUOTE, BACK_QUOTE, BRACKET. If not specified, value from lex is used.
quotedCasingHow identifiers are stored if they are quoted. Values are UNCHANGED, TO_UPPER, TO_LOWER. If not specified, value from lex is used.
schemaName of initial schema.
schemaFactorySchema factory. The name of a class that implements SchemaFactory and has a public default constructor or an INSTANCE constant. Ignored if model is specified.
schemaTypeSchema type. Value must be “MAP” (the default), “JDBC”, or “CUSTOM” (implicit if schemaFactory is specified). Ignored if model is specified.
sparkSpecifies whether Spark should be used as the engine for processing that cannot be pushed to the source system. If false (the default), Calcite generates code that implements the Enumerable interface.
timeZoneTime zone, for example “gmt-3”. Default is the JVM's time zone.
typeSystemType system. The name of a class that implements RelDataTypeSystem and has a public default constructor or an INSTANCE constant.
unquotedCasingHow identifiers are stored if they are not quoted. Values are UNCHANGED, TO_UPPER, TO_LOWER. If not specified, value from lex is used.

To make a connection to a single schema based on a built-in schema type, you don't need to specify a model. For example,

jdbc:calcite:schemaType=JDBC; schema.jdbcUser=SCOTT; schema.jdbcPassword=TIGER; schema.jdbcUrl=jdbc:hsqldb:res:foodmart

creates a connection with a schema mapped via the JDBC schema adapter to the foodmart database.

Similarly, you can connect to a single schema based on a user-defined schema adapter. For example,

jdbc:calcite:schemaFactory=org.apache.calcite.adapter.cassandra.CassandraSchemaFactory; schema.host=localhost; schema.keyspace=twissandra

makes a connection to the Cassandra adapter, equivalent to writing the following model file:

{% highlight json %} { “version”: “1.0”, “defaultSchema”: “foodmart”, “schemas”: [ { type: ‘custom’, name: ‘twissandra’, factory: ‘org.apache.calcite.adapter.cassandra.CassandraSchemaFactory’, operand: { host: ‘localhost’, keyspace: ‘twissandra’ } } ] } {% endhighlight %}

Note how each key in the operand section appears with a schema. prefix in the connect string.