This is a prerelease version.

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.

  • No support for window functions.

    You cannot group or aggregate results in streaming queries.

Supported Statements

Hazelcast supports a subset of standard ANSI SQL statements as well as some custom ones for creating jobs, mappings, and streaming queries.

For a list of supported statements, see SQL Statements.

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.