- Batch SQL Examples
Batch SQL Examples
Submit SQL Query via SQL Client
First, modify the sql client config file ./conf/sql-client-defaults.yaml to set execution type to
Then, start local cluster:
Check the web at http://localhost:8081 and make sure everything is up and running. The web frontend should report a single available TaskManager instance.
Prepare the input data:
Then start SQL Client shell:
You can see the welcome message for flink sql client.
Paste the following sql ddl text into the shell. (For more information about sql ddl refer to SQL and Supported DDL)
Press ‘Enter’ and paste the following sql dml text.
After press ‘Enter’ the sql will be submitted to the standalone cluster. The result will print on the shell.
Open http://localhost:8081 and you can see the job information.
For more information please refer to SQL and SQL Client.
Submit SQL Query Programmatically
SQL queries can be submitted using the
sqlQuery() method of the TableEnvironment programmatically.
WordCountSQL shows how the Batch SQL API is used in Java.
The WordCountSQL implements the above described algorithm.
The WordCountSQL.scala implements the above described algorithm.
To run the example, issue the following command and the result will print on the shell:
Open http://localhost:8081 and you can see the dashboard.
Clink the job name: “Flink Exec Table Job”, and you can see the detailed info page:
Back to top