A script can contain the CALL command and DDL, DQL, and DML statements. You can use scripts to create and manage catalogs and tables, perform data queries, and manage Apache Paimon tables. You can use the Explain statement in a script to view execution plans and troubleshoot issues.
Features
Verifies SQL syntax. A script cannot run if the verification fails.
Run all or selected statements in a script.
Supports the
CALLcommand and DDL, DQL, and DML statements.ImportantExecuting DDL or DML statements directly can impact your metadata or data. Proceed with care.
Automatically saves your script every minute. You can also manually save a temporary query to a folder.
Procedure
Log on to the Realtime Compute for Apache Flink's Management Console.
In the Actions column of your workspace, click Console.
In the Development Console, navigate to and click the Scripts tab.
Click
to create a script.Enter your SQL code.
The code snippet below creates a MySQL catalog:
Create a MySQL catalog. For details, see Create a MySQL catalog.
CREATE CATALOG mysql_catalog WITH( 'type' = 'mysql', 'hostname' = 'rm-bp1x********.mysql.rds.aliyuncs.com', 'port' = '3306', 'username' = 'db_user', 'password' = '${secret_values.mysqlpw}', 'default-database' = 'flinktest' );Query the table:
Batch (batch): Used only for bounded datasets (fixed volume) and provides higher efficiency.
Streaming: Used for both bounded and unbounded datasets (unknown or infinite size). To switch to streaming mode, explicitly specify the
SETstatement.NoteScripts do not support variables.
SET 'execution.runtime-mode' = 'streaming'; SELECT * FROM `mysql_catalog`.flinktest.orders;
Select or create a session cluster.
In the lower-right corner of the page, click Environment and select a session cluster of Ververica Runtime (VVR) 8.0.4 or later. If no session cluster exists, create a session cluster.
Select the target code snippet and click Run to the left of the snippet.
(Optional) In the upper-right corner, click Save. Specify a file name and a storage location.
FAQ
Why do I get the error "Querying an unbounded table 'XXX' in batch mode is not allowed. The table source is unbounded." when running a script?
Cause
The source is an unbounded stream and requires streaming mode. The data stream types are defined as follows:
Bounded stream: The size of the dataset is fixed.
Unbounded stream: The size of the dataset is unknown or infinite.
Solution
Use the SET syntax to switch to streaming mode.
SET 'execution.runtime-mode' = 'streaming';