The SQL Gateway is a long-running service that enables multiple clients to concurrently execute SQL queries against Flink via a REST API or HiveServer2 protocol.
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.
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).
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:
Sessions are isolated contexts. Each session maintains its own:
Catalog and database context
Configuration properties (SET statements)
Registered temporary tables and views
Sessions expire after the configured sql-gateway.session.timeout (default: 10 minutes of inactivity).
For long-running operations, use the SQL Gateway with --endpoint mode from the SQL Client so that the SQL Client is just a thin frontend — the actual processing happens inside the gateway service.
Each session competes for memory and execution resources. In production, limit sql-gateway.session.max-num and set an appropriate sql-gateway.session.timeout to prevent resource exhaustion.