The SQL Gateway is a standalone service that exposes Flink’s SQL capabilities over a network protocol. Unlike the embedded SQL Client, the SQL Gateway is designed for production environments where multiple applications or users need to submit SQL queries concurrently to a shared Flink cluster.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/apache/flink/llms.txt
Use this file to discover all available pages before exploring further.
REST Endpoint
Submit SQL via HTTP/REST — suitable for applications, notebooks, and BI tools using JDBC.
HiveServer2 Endpoint
Connect with tools that speak the HiveServer2 protocol (Beeline, DBeaver, Tableau).
Architecture
The SQL Gateway is composed of:- SqlGatewayService — the core processing engine that manages sessions and executes statements
- Endpoints — pluggable network listeners (REST, HiveServer2) that accept client connections
Starting the SQL Gateway
Start the SQL Gateway
Start the SQL Gateway with the REST endpoint:The gateway listens on port
8083 by default.REST API
The SQL Gateway REST API lets you open sessions, execute statements, and retrieve results programmatically.Open a session
sessionHandle identifies your session for all subsequent requests.
Execute a SQL statement
Poll for results
Close a session
Key REST endpoints
| Method | Path | Description |
|---|---|---|
GET | /v1/info | Gateway version info |
POST | /v1/sessions | Open a new session |
DELETE | /v1/sessions/{handle} | Close a session |
GET | /v1/sessions/{handle} | Get session configuration |
POST | /v1/sessions/{handle}/statements | Execute a SQL statement |
GET | /v1/sessions/{handle}/operations/{opHandle}/result/{token} | Fetch results |
DELETE | /v1/sessions/{handle}/operations/{opHandle} | Cancel an operation |
GET | /v1/sessions/{handle}/operations/{opHandle}/status | Get operation status |
HiveServer2 endpoint
The SQL Gateway can optionally expose a HiveServer2-compatible endpoint, allowing tools that support the HiveServer2 protocol to connect directly. Enable HiveServer2 in the Flink configuration:config.yaml
localhost:10000.
HiveServer2 compatibility mode requires the Hive connector to be on the classpath. Add
flink-connector-hive to lib/.Configuration
Endpoint configuration
config.yaml
Connecting from the SQL Client
Use the SQL Client in gateway mode to send queries to the SQL Gateway:Managing sessions
Sessions are isolated contexts. Each session maintains its own:- Catalog and database context
- Configuration properties (SET statements)
- Registered temporary tables and views
sql-gateway.session.timeout (default: 10 minutes of inactivity).

