Configure a Streaming SQL job
This topic describes how to configure a Streaming SQL job.
Background information
When configuring a Streaming SQL job, you must specify its dependency libraries. The following table lists the available data source dependency bundles. We recommend using the latest version.
|
Library name |
Version |
Release date |
Reference string |
Description |
|
datasources-bundle |
2.0.0 (recommended) |
2020-02-26 |
sharedlibs:streamingsql:datasources-bundle:2.0.0 |
Supported data sources: Kafka, LogHub, Druid, Tablestore, HBase, JDBC, DataHub, Redis, Kudu, and DTS. |
|
1.9.0 |
2019-11-20 |
sharedlibs:streamingsql:datasources-bundle:1.9.0 |
Supported data sources: Kafka, LogHub, Druid, Tablestore, HBase, JDBC, DataHub, Redis, and Kudu. |
|
|
1.8.0 |
2019-10-17 |
sharedlibs:streamingsql:datasources-bundle:1.8.0 |
Supported data sources: Kafka, LogHub, Druid, Tablestore, HBase, JDBC, DataHub, and Redis. |
|
|
1.7.0 |
2019-07-29 |
sharedlibs:streamingsql:datasources-bundle:1.7.0 |
Supported data sources: Kafka, LogHub, Druid, Tablestore, HBase, and JDBC. |
Prerequisites
-
You have created a project. For more information, see Project Management.
-
Ensure you have the required resources and data files for the job, such as the JAR package, data file names, and their storage paths.
Procedure
-
Go to the Projects page in Data Platform.
-
Log in to the E-MapReduce console with your Alibaba Cloud account.
-
In the top navigation bar, select the region and resource group.
-
Click the Data Development tab.
-
-
In the row of the project you want to edit, click Edit Job.
-
Create a Streaming SQL job.
- On the left side of the page, right-click the target folder and select Create Job.
-
In the Create Job dialog box, enter a Job Name and Description for the job, and select Streaming SQL from the Job Type drop-down list.
- Click OK.
-
Edit the job content.
In the Content section, enter the SQL statements for the job. The following code is an example.
--- Create a Log Service (SLS) table. CREATE TABLE IF NOT EXISTS ${slsTableName} USING loghub OPTIONS ( sls.project = '${logProjectName}', sls.store = '${logStoreName}', access.key.id = '${accessKeyId}', access.key.secret = '${accessKeySecret}', endpoint = '${endpoint}' ); --- Import data into HDFS. INSERT INTO ${hdfsTableName} SELECT col1, col2 FROM ${slsTableName} WHERE ${condition}NoteThis type of job is submitted by using the
streaming-sql -f {sql_script}command. Thesql_scriptfile contains the SQL statements from the job editor. -
Configure dependency libraries and a failure handling policy.
-
In the upper-right corner, click Job Settings.
-
On the Shared Libraries and Streaming Task Settings tabs, configure dependency libraries and a failure handling policy.
Section
Parameter
Description
Dependency libraries
Libraries
Jobs rely on dependency libraries for specific data sources. Alibaba Cloud E-MapReduce provides these libraries in a service repository. When creating a job, you must specify a library version.
You only need to specify the reference string for the required version, such as sharedlibs:streamingsql:datasources-bundle:2.0.0.
Failure Handling Policy
On current statement failure
Sets the action to take if the current statement fails to execute.
-
Execute next statement: If a query statement fails, the job proceeds to the next statement.
-
Terminate job: If a query statement fails, the job terminates.
-
-
Click Save to save the job content and its configuration.
-