diff --git a/docs/content.zh/docs/dev/table/sql-gateway/overview.md b/docs/content.zh/docs/dev/table/sql-gateway/overview.md
index 7848ed64a2d0c..1a6118e0021ce 100644
--- a/docs/content.zh/docs/dev/table/sql-gateway/overview.md
+++ b/docs/content.zh/docs/dev/table/sql-gateway/overview.md
@@ -116,6 +116,34 @@ $ curl --request GET http://localhost:8083/v1/sessions/${sessionHandle}/operatio
结果中的 `nextResultUri` 不是null时,用于获取下一批结果。
+### Deploy Script
+
+SQL Gateway supports to deploy a script in [Application Mode]({{< ref "docs/deployment/overview" >}}). In application mode, Job Master is responsible for the script compiling.
+If you want to use custom resources in the script, e.g. Kafka Source, please use [ADD JAR]({{< ref "docs/dev/table/sql/jar">}}) command to download the required sources.
+
+Here is an example to deploy script to Flink native K8S Cluster with cluster id `CLUSTER_ID`.
+
+```bash
+$ curl --request POST http://localhost:8083/sessions/${SESSION_HANDLE}/scripts \
+--header 'Content-Type: application/json' \
+--data-raw '{
+ "script": "CREATE TEMPORARY TABLE sink(a INT) WITH ( '\''connector'\'' = '\''blackhole'\''); INSERT INTO sink VALUES (1), (2), (3);",
+ "executionConfig": {
+ "execution.target": "kubernetes-application",
+ "kubernetes.cluster-id": "'${CLUSTER_ID}'",
+ "kubernetes.container.image.ref": "'${FLINK_IMAGE_NAME}'",
+ "jobmanager.memory.process.size": "1000m",
+ "taskmanager.memory.process.size": "1000m",
+ "kubernetes.jobmanager.cpu": 0.5,
+ "kubernetes.taskmanager.cpu": 0.5,
+ "kubernetes.rest-service.exposed.type": "NodePort"
+ }
+}'
+```
+
+Note If you want to run script with PyFlink, please use an image with PyFlink installed. You can refer to
+[Enabling PyFlink in docker]({{< ref "docs/deployment/resource-providers/standalone/docker" >}}#enabling-python) for more details.
+
```bash
$ curl --request GET ${nextResultUri}
```
diff --git a/docs/content.zh/docs/dev/table/sql-gateway/rest.md b/docs/content.zh/docs/dev/table/sql-gateway/rest.md
index 6f0cc482021fb..4888df77b961a 100644
--- a/docs/content.zh/docs/dev/table/sql-gateway/rest.md
+++ b/docs/content.zh/docs/dev/table/sql-gateway/rest.md
@@ -93,11 +93,13 @@ REST API
OpenAPI 规范如下,默认版本是 v3。
-| Version | Description |
-| ----------- |--------------------------------|
-| [Open API v1 specification]({{< ref_static "generated/rest_v1_sql_gateway.yml" >}}) | 允许用户提交 SQL 语句到 Gateway 并执行。 |
-| [Open API v2 specification]({{< ref_static "generated/rest_v2_sql_gateway.yml" >}}) | 支持 SQL 客户端连接到 Gateway。 |
-| [Open API v3 specification]({{< ref_static "generated/rest_v3_sql_gateway.yml" >}}) | 支持 Materialized Table 刷新操作。 |
+| Version | Description |
+| ----------- |-------------------------------|
+| [Open API v1 specification]({{< ref_static "generated/rest_v1_sql_gateway.yml" >}}) | 允许用户提交 SQL 语句到 Gateway 并执行。 |
+| [Open API v2 specification]({{< ref_static "generated/rest_v2_sql_gateway.yml" >}}) | 支持 SQL 客户端连接到 Gateway。 |
+| [Open API v3 specification]({{< ref_static "generated/rest_v3_sql_gateway.yml" >}}) | 支持 Materialized Table 刷新操作。 |
+| [Open API v4 specification]({{< ref_static "generated/rest_v4_sql_gateway.yml" >}}) | 支持使用 Application 模式部署 SQL 脚本。 |
+
{{< hint warning >}}
OpenAPI 规范目前仍处于实验阶段。
@@ -106,6 +108,11 @@ OpenAPI 规范目前仍处于实验阶段。
#### API reference
{{< tabs "f00ed142-b05f-44f0-bafc-799080c1d40d" >}}
+{{< tab "v4" >}}
+
+{{< generated/rest_v4_sql_gateway >}}
+
+{{< /tab >}}
{{< tab "v3" >}}
{{< generated/rest_v3_sql_gateway >}}
diff --git a/docs/content.zh/docs/dev/table/sqlClient.md b/docs/content.zh/docs/dev/table/sqlClient.md
index 9fc664fbc34ef..273e9f5008c93 100644
--- a/docs/content.zh/docs/dev/table/sqlClient.md
+++ b/docs/content.zh/docs/dev/table/sqlClient.md
@@ -610,7 +610,7 @@ SQL Client will print success message if the statement is executed successfully.
By default, the error message only contains the error cause. In order to print the full exception stack for debugging, please set the
`sql-client.verbose` to true through command `SET 'sql-client.verbose' = 'true';`.
-### Execute SQL Files
+### Execute SQL Files in a Session Cluster
SQL Client supports to execute a SQL script file with the `-f` option. SQL Client will execute
statements one by one in the SQL script file and print execution messages for each executed statements.
@@ -663,6 +663,24 @@ This configuration:
Attention Compared to the interactive mode, SQL Client will stop execution and exits when there are errors.
+### Deploy SQL Files in an Application Cluster
+
+SQL Client also supports to deploy a SQL script file to an application cluster with the `-f` option if you specify the deployment target in the config.yaml or startup options.
+Here is an example to deploy script file in an application cluster.
+
+```bash
+./bin/sql-client.sh -f oss://path/to/script.sql \
+ -Dexecution.target=kubernetes-application \
+ -Dkubernetes.cluster-id=${CLUSTER_ID} \
+ -Dkubernetes.container.image.ref=${FLINK_IMAGE_NAME}'
+```
+
+After execution, SQL Client print the cluster id on the terminal. The script can contain any statement that is supported by Flink. But Application cluster only supports one job, please refer to the
+[Application Mode]({{< ref "docs/deployment/overview#application-mode" >}}) for the limitations.
+
+Attention When deploying a script to the cluster, SQL Client only supports to run with `--jars` startup option, other options, e.g. `--init`
+are not supported.
+
### Execute a set of SQL statements
SQL Client execute each INSERT INTO statement as a single Flink job. However, this is sometimes not
diff --git a/docs/content/docs/dev/table/sql-gateway/overview.md b/docs/content/docs/dev/table/sql-gateway/overview.md
index a46c2628c050f..037c456dee1a2 100644
--- a/docs/content/docs/dev/table/sql-gateway/overview.md
+++ b/docs/content/docs/dev/table/sql-gateway/overview.md
@@ -122,6 +122,34 @@ The `nextResultUri` in the results is used to fetch the next batch results if it
$ curl --request GET ${nextResultUri}
```
+### Deploy Script
+
+SQL Gateway supports to deploy a script in [Application Mode]({{< ref "docs/deployment/overview" >}}). In application mode, Job Master is responsible for the script compiling.
+If you want to use custom resources in the script, e.g. Kafka Source, please use [ADD JAR]({{< ref "docs/dev/table/sql/jar">}}) command to download the required sources.
+
+Here is an example to deploy script to Flink native K8S Cluster with cluster id `CLUSTER_ID`.
+
+```bash
+$ curl --request POST http://localhost:8083/sessions/${SESSION_HANDLE}/scripts \
+--header 'Content-Type: application/json' \
+--data-raw '{
+ "script": "CREATE TEMPORARY TABLE sink(a INT) WITH ( '\''connector'\'' = '\''blackhole'\''); INSERT INTO sink VALUES (1), (2), (3);",
+ "executionConfig": {
+ "execution.target": "kubernetes-application",
+ "kubernetes.cluster-id": "'${CLUSTER_ID}'",
+ "kubernetes.container.image.ref": "'${FLINK_IMAGE_NAME}'",
+ "jobmanager.memory.process.size": "1000m",
+ "taskmanager.memory.process.size": "1000m",
+ "kubernetes.jobmanager.cpu": 0.5,
+ "kubernetes.taskmanager.cpu": 0.5,
+ "kubernetes.rest-service.exposed.type": "NodePort"
+ }
+}'
+```
+
+Note If you want to run script with PyFlink, please use an image with PyFlink installed. You can refer to
+[Enabling PyFlink in docker]({{< ref "docs/deployment/resource-providers/standalone/docker" >}}#enabling-python) for more details.
+
Configuration
----------------
diff --git a/docs/content/docs/dev/table/sql-gateway/rest.md b/docs/content/docs/dev/table/sql-gateway/rest.md
index eafefaad72b89..40d109abbbbd1 100644
--- a/docs/content/docs/dev/table/sql-gateway/rest.md
+++ b/docs/content/docs/dev/table/sql-gateway/rest.md
@@ -96,11 +96,12 @@ REST API
The available OpenAPI specification is as follows. The default version is v3.
-| Version | Description |
-| ----------- | ------- |
+| Version | Description |
+|-------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [Open API v1 specification]({{< ref_static "generated/rest_v1_sql_gateway.yml" >}}) | Allow users to submit statements to the gateway and execute. |
-| [Open API v2 specification]({{< ref_static "generated/rest_v2_sql_gateway.yml" >}}) | Supports SQL Client to connect to the gateway. |
-| [Open API v3 specification]({{< ref_static "generated/rest_v3_sql_gateway.yml" >}}) | Supports Materialized Table refresh operation. |
+| [Open API v2 specification]({{< ref_static "generated/rest_v2_sql_gateway.yml" >}}) | Supports SQL Client to connect to the gateway. |
+| [Open API v3 specification]({{< ref_static "generated/rest_v3_sql_gateway.yml" >}}) | Supports Materialized Table refresh operation. |
+| [Open API v4 specification]({{< ref_static "generated/rest_v4_sql_gateway.yml" >}}) | Supports to deploy script in application mode. |
{{< hint warning >}}
The OpenAPI specification is still experimental.
@@ -109,6 +110,11 @@ The OpenAPI specification is still experimental.
#### API reference
{{< tabs "f00ed142-b05f-44f0-bafc-799080c1d40d" >}}
+{{< tab "v4" >}}
+
+{{< generated/rest_v4_sql_gateway >}}
+
+{{< /tab >}}
{{< tab "v3" >}}
{{< generated/rest_v3_sql_gateway >}}
diff --git a/docs/content/docs/dev/table/sqlClient.md b/docs/content/docs/dev/table/sqlClient.md
index 55405d049f057..3b30ffc7973c6 100644
--- a/docs/content/docs/dev/table/sqlClient.md
+++ b/docs/content/docs/dev/table/sqlClient.md
@@ -548,7 +548,7 @@ SQL Client will print success message if the statement is executed successfully.
By default, the error message only contains the error cause. In order to print the full exception stack for debugging, please set the
`sql-client.verbose` to true through command `SET 'sql-client.verbose' = 'true';`.
-### Execute SQL Files
+### Execute SQL Files in a Session Cluster
SQL Client supports to execute a SQL script file with the `-f` option. SQL Client will execute
statements one by one in the SQL script file and print execution messages for each executed statements.
@@ -601,6 +601,24 @@ This configuration:
Attention Compared to the interactive mode, SQL Client will stop execution and exits when there are errors.
+### Deploy SQL Files in an Application Cluster
+
+SQL Client also supports to deploy a SQL script file to an application cluster with the `-f` option if you specify the deployment target in the config.yaml or startup options.
+Here is an example to deploy script file in an application cluster.
+
+```bash
+./bin/sql-client.sh -f oss://path/to/script.sql \
+ -Dexecution.target=kubernetes-application \
+ -Dkubernetes.cluster-id=${CLUSTER_ID} \
+ -Dkubernetes.container.image.ref=${FLINK_IMAGE_NAME}'
+```
+
+After execution, SQL Client print the cluster id on the terminal. The script can contain any statement that is supported by Flink. But Application cluster only supports one job, please refer to the
+[Application Mode]({{< ref "docs/deployment/overview#application-mode" >}}) for the limitations.
+
+Attention When deploying a script to the cluster, SQL Client only supports to run with `--jars` startup option, other options, e.g. `--init`
+are not supported.
+
### Execute a set of SQL statements
SQL Client execute each INSERT INTO statement as a single Flink job. However, this is sometimes not
diff --git a/docs/layouts/shortcodes/generated/rest_v4_sql_gateway.html b/docs/layouts/shortcodes/generated/rest_v4_sql_gateway.html
new file mode 100644
index 0000000000000..94c47f1fc8d2a
--- /dev/null
+++ b/docs/layouts/shortcodes/generated/rest_v4_sql_gateway.html
@@ -0,0 +1,746 @@
+
+
+
+
/api_versions
+
+
+
Verb: GET
+
Response code: 200 OK
+
+
+
Get the current available versions for the Rest Endpoint. The client can choose one of the return version as the protocol for later communicate.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/info
+
+
+
Verb: GET
+
Response code: 200 OK
+
+
+
Get meta data for this cluster.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/sessions
+
+
+
Verb: POST
+
Response code: 200 OK
+
+
+
Opens a new session with specific properties. Specific properties can be given for current session which will override the default properties of gateway.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/sessions/:session_handle
+
+
+
Verb: DELETE
+
Response code: 200 OK
+
+
+
Closes the specific session.
+
+
+
Path parameters
+
+
+
+
+
session_handle - The SessionHandle that identifies a session.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/sessions/:session_handle
+
+
+
Verb: GET
+
Response code: 200 OK
+
+
+
Get the session configuration.
+
+
+
Path parameters
+
+
+
+
+
session_handle - The SessionHandle that identifies a session.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/sessions/:session_handle/complete-statement
+
+
+
Verb: GET
+
Response code: 200 OK
+
+
+
Get the completion hints for the given statement at the given position.
+
+
+
Path parameters
+
+
+
+
+
session_handle - The SessionHandle that identifies a session.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/sessions/:session_handle/configure-session
+
+
+
Verb: POST
+
Response code: 200 OK
+
+
+
Configures the session with the statement which could be:
+CREATE TABLE, DROP TABLE, ALTER TABLE, CREATE DATABASE, DROP DATABASE, ALTER DATABASE, CREATE FUNCTION, DROP FUNCTION, ALTER FUNCTION, CREATE CATALOG, DROP CATALOG, USE CATALOG, USE [CATALOG.]DATABASE, CREATE VIEW, DROP VIEW, LOAD MODULE, UNLOAD MODULE, USE MODULE, ADD JAR.
+
+
+
Path parameters
+
+
+
+
+
session_handle - The SessionHandle that identifies a session.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
/sessions/:session_handle/heartbeat
+
+
+
Verb: POST
+
Response code: 200 OK
+
+
+
Trigger heartbeat to tell the server that the client is active, and to keep the session alive as long as configured timeout value.
+
+
+
Path parameters
+
+
+
+
+
session_handle - The SessionHandle that identifies a session.