A newer version of Hazelcast Platform is available.

View latest

SQL Overview

You can use SQL to query data in maps, Kafka topics, or a variety of file systems. Results can be sent directly to the client or inserted into maps or Kafka topics. For streaming queries, you can submit them to a cluster as jobs to run in the background.

Supported Queries

You can run the following queries with SQL.

For a hands-on introduction to SQL, see Get Started with SQL Over Maps.

Query

Description

Tutorial

Ad-hoc queries

Query large datasets either in one or multiple systems and/or run aggregations on them to get deeper insights.

Streaming queries, also known as continuous queries.

Keep an open connection to a streaming data source and run a continuous query to get near real-time updates.

Federated queries

Query different datasets such as Kafka topics and Hazelcast maps, using a single query. Normally, querying in SQL is database or dataset-specific. However, with mappings, you can pull information from different sources to present a more complete picture.

Mappings

To connect to data sources and query them as if they were tables, the SQL service uses a concept called mappings.

Mappings store essential metadata about the source’s data model, data access patterns, and serialization formats so that the SQL service can connect to the data source and query it.

You can create mappings for the following data sources by using the CREATE MAPPING statement:

Case Sensitivity

Mapping names and field names are case-sensitive.

For example, you can access an employee map as employee but not as Employee.

Limitations

SQL has the following limitations. We plan to remove these limitations in future releases.

  • The only supported Hazelcast data structure is map.

    You cannot query other data structures such as replicated maps.

  • No support for the CREATE INDEX statement.

    To create indexes for maps in Hazelcast, see Indexing Maps

  • No support for the JSON type.

    You can’t use functions such as JSON_VALUE or JSON_QUERY.

  • Limited support for joins.

  • You cannot run SQL queries on lite members. This limitation will be removed in future releases.

  • You cannot persist SQL metadata on disk. This means that when a cluster restarts, it does not retain any SQL mappings or views that you have created.

How Hazelcast Executes SQL Statements

When an SQL statement is submitted for execution, the SQL service parses and optimizes it using Apache Calcite. The result is an executable plan in the form of a Jet graph that is cached and reused by subsequent executions of the same statement.

For details about how the Jet engine models data into graphs, see How Hazelcast Models and Executes Jobs.