Nikita-tech-writer commented on code in PR #10002: URL: https://github.com/apache/ignite/pull/10002#discussion_r861072935
########## docs/_docs/SQL/sql-calcite.adoc: ########## @@ -0,0 +1,251 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. += Calcite-based SQL engine + +Apache Ignite since 2.13 version includes the new SQL engine based on the Apache Calcite framework. + +Apache Calcite is a dynamic data management framework, which mainly serves for mediating between applications and one or more data storage locations and data processing engines. For more information on Apache Calcite, please see the link:https://calcite.apache.org/docs[product documentation, window=_blank]. + +Current H2-based SQL engine has some fundamental limitations of query execution in distributed environment. To address these limitations the new SQL engine was developed. The new engine uses tools, provided by Apache Calcite, for parsing and planning queries, and has a new query execution flow. + +CAUTION: The Calcite-based query engine is currently in beta status. + +== Calcite module libraries + +To use Calcite-based engine Calcite module libraries should be in a classpath. + +CAUTION: At now some logic from `ignite-indexing` module is reused, this means `ignite-indexing` module also has to be present at classpath. + +=== Standalone mode + +When starting a standalone node, move `optional/ignite-calcite` and `optional/ignite-slf4j` folders to `libs` folder before running `ignite.{sh|bat}` script. The content of the module folder will be added to classpath in this case. + +=== Maven configuration + +If you are using Maven to manage dependencies of your project, you can add Calcite module dependency like this (replace `${ignite.version}` with the actual Apache Ignite version you are interested in): + +[tabs] +-- +tab:XML[] +[source,xml] +---- +<dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-calcite</artifactId> + <version>${ignite.version}</version> +</dependency> +---- +-- + +== Configuring query engines + +To enable engine for queries explicit `CalciteQueryEngineConfiguration` instance should be added to `SqlConfiguration.QueryEnginesConfiguration` property. + +Here is config example with two query engines configured (H2-based and Calcite-based) and Calcite-based engine chosen as default: + +[tabs] +-- +tab:XML[] +[source,xml] +---- +<bean class="org.apache.ignite.configuration.IgniteConfiguration"> + <property name="sqlConfiguration"> + <bean class="org.apache.ignite.configuration.SqlConfiguration"> + <property name="queryEnginesConfiguration"> + <list> + <bean class="org.apache.ignite.indexing.IndexingQueryEngineConfiguration"> + <property name="default" value="false"/> + </bean> + <bean class="org.apache.ignite.calcite.CalciteQueryEngineConfiguration"> + <property name="default" value="true"/> + </bean> + </list> + </property> + </bean> + </property> + ... +</bean> +---- +tab:Java[] +[source,java] +---- +IgniteConfiguration cfg = new IgniteConfiguration().setSqlConfiguration( + new SqlConfiguration().setQueryEnginesConfiguration( + new IndexingQueryEngineConfiguration(), + new CalciteQueryEngineConfiguration().setDefault(true) + ) +); +---- +-- + +== Routing queries to query engine + +All querues by default are routed to the configured default query engine, but if more than one engine configured throught `queryEnginesConfiguration` it's possible to use not default configured engine for individual queries or for the whole connection. + +=== JDBC connection configuration + +To choose query engine for JDBC connection `queryEngine` connection parameter can be used. + +Example: + +[tabs] +-- +tab:JDBC Connection url[] +[source,text] +---- +jdbc:ignite:thin://127.0.0.1:10800?queryEngine=calcite +---- +-- + +=== ODBC connection configuration + +For ODBC connection query engine can be configured by `QUERY_ENGINE` property. + +Example: + +[tabs] +-- +tab:ODBC Connection properties[] +[source,text] +---- +[IGNITE_CALCITE] +DRIVER={Apache Ignite}; +SERVER=127.0.0.1; +PORT=10800; +SCHEMA=PUBLIC; +QUERY_ENGINE=CALCITE +---- +-- + +=== QUERY_ENGINE hint + +For individual queries exact engine to run query can be selected using `QUERY_ENGINE` hint. + +Example: + +[tabs] +-- +tab:Query with QUERY_ENGINE hint[] +[source,sql] +---- +SELECT /*+ QUERY_ENGINE('calcite') */ fld FROM table; +---- +-- + +== SQL reference + +=== DDL + +Data definition language (DDL) statements are compilant with the old, H2-based engine. You can find DDL syntax description link:sql-reference/ddl[here]. + +=== DML + +The new SQL engine mostly inherit Data manipulation language (DML) statements syntax from the Apache Calcite framework. Apache Calcite SQL grammer description can be found link:https://calcite.apache.org/docs/reference.html[here, window=_blank]. + +In the most cases statements syntax is compilant with the old SQL engine. But there are also some differences between DML dialects in H2-based engine and Calcite-based engine. For example, note MERGE statement syntax change if you use this statement. + +=== Supported functions Review Comment: ```suggestion === Supported Functions ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org