This topic describes how to develop an SQL draft in the console of fully managed Flink.
When you write code for an SQL draft, you can use various built-in connectors that are provided by fully managed Flink, user-defined functions (UDFs), and custom connectors. For more information about the usage scenarios and methods of built-in connectors, UDFs, and custom connectors, see the following topics:
Log on to the console of fully managed Flink and create an SQL draft.
Log on to the Realtime Compute for Apache Flink console.
On the Fully Managed Flink tab, find the workspace that you want to manage and click Console in the Actions column.
In the left-side navigation pane, click SQL Editor. In the upper-left corner of the SQL Editor page, click New.
On the SQL Scripts tab of the New Draft dialog box, click Blank Stream Draft.
Fully managed Flink provides various SQL code templates and supports data synchronization. Each code template provides specific scenarios, code samples, and instructions for you. You can click the desired template to quickly learn about the features and related syntax of Flink and implement your business logic. For more information, see Code templates and Data synchronization templates.
In the New Draft dialog box, configure the parameters of the draft. The following table describes the parameters.
The name of the draft that you want to create.Note
The draft name must be unique in the current project.
The folder in which the code file of the draft is saved.
You can also click the icon to the right of an existing folder to create a subfolder.
The engine version of Flink that is used by the draft. For more information about engine versions, version mappings, and important time points in the lifecycle of each version, see Engine version.
Write DDL and DML statements.Note
The metadata management feature allows you to reuse the table schema that is created in different drafts. When you edit an SQL draft on the SQL Editor page in the console of fully managed Flink, the system automatically completes the fields and table names after you enter only specific characters.
-- Create a source table named datagen_source. CREATE TEMPORARY TABLE datagen_source( name VARCHAR ) WITH ( 'connector' = 'datagen' ); -- Create a result table named blackhole_sink. CREATE TEMPORARY TABLE blackhole_sink( name VARCHAR ) WITH ( 'connector' = 'blackhole' ); -- Insert data from the source table datagen_source into the result table blackhole_sink. INSERT INTO blackhole_sink SELECT name from datagen_source;
On the right-side of the SQL Editor page, click a desired tab to view or enter the configuration information on the tab based on your business requirements.
Engine Version: the version of the Flink engine that you select when you create the draft. For more information about engine versions, see Engine versions and Lifecycle policies. We recommend that you use a recommended version or a stable version. Valid values:
Recommend: the latest minor version of the current major version.
Stable: the latest minor version of the major version that is still in use within the validity period for renewal. Defects in previous versions are fixed.
Normal: other minor versions that are still in use within the validity period for renewal.
Deprecated: the version that expires.
Additional Dependencies: the additional dependencies that are used in the draft, such as temporary functions.
Flow Diagram: the flow diagram that allows you to view the directions in which data flows.
Tree Diagram: the tree diagram that allows you to view the source from which data is processed.
You can view the engine version of the deployment. For more information about the operations that you can perform in the Actions column in the Draft Versions panel, see Manage deployment versions.
Check the SQL semantics of the draft, network connectivity, and the metadata information of the tables that are used by the draft. You can also click SQL Advice in the calculated results to view information about SQL risks and related optimization suggestions.
Optional: Click Debug.
You can enable the debugging feature to simulate deployment running, check outputs, and verify the business logic of SELECT and INSERT statements. This feature improves development efficiency and reduces the risks of poor data quality. For more information, see Debug a deployment.
After the draft development and syntax check are complete, you can deploy the draft to publish the data to the production environment. After the draft is deployed, you can start the deployment for the draft on the Deployments page to run the deployment. For more information, see Start a deployment.