The Print connector is used to print output data to the error file or TaskManager file, making it easier for you to view the result in code debugging.
None
Condition 1 |
Condition 2 |
|
---|---|---|
Identifier:Task ID> Output data |
A print identifier prefix must be provided. That is, you must specify print-identifier in the WITH parameter when creating the Print result table. |
parallelism > 1 |
Identifier> Output data |
A print identifier prefix must be provided. That is, you must specify print-identifier in the WITH parameter when creating the Print result table. |
parallelism == 1 |
Task ID> Output data |
A print identifier prefix is not needed. That is, you do not specify print-identifier in the WITH parameter when creating the Print result table. |
parallelism > 1 |
Output data |
A print identifier prefix is not needed. That is, you do not specify print-identifier in the WITH parameter when creating the Print result table. |
parallelism == 1 |
1 2 3 4 5 6 7 8 9 | create table printSink ( attr_name attr_type (',' attr_name attr_type) * (',' PRIMARY KEY (attr_name,...) NOT ENFORCED) ) with ( 'connector' = 'print', 'print-identifier' = '', 'standard-error' = '' ); |
Parameter |
Mandatory |
Default Value |
Data Type |
Description |
---|---|---|---|---|
connector |
Yes |
None |
String |
Connector to be used. Set this parameter to print. |
print-identifier |
No |
None |
String |
Message that identifies print and is prefixed to the output of the value. |
standard-error |
No |
false |
Boolean |
The value can be only true or false. The default value is false.
|
Create a Flink OpenSource SQL job. Run the following script to generate random data through the DataGen table and output the data to the Print result table.
When you create a job, set Flink Version to 1.12 on the Running Parameters tab. Select Save Job Log, and specify the OBS bucket for saving job logs.
create table dataGenSOurce( user_id string, amount int ) with ( 'connector' = 'datagen', 'rows-per-second' = '1', --Generate a piece of data per second. 'fields.user_id.kind' = 'random', --Specify a random generator for the user_id field. 'fields.user_id.length' = '3' --Limit the length of user_id to 3. ); create table printSink( user_id string, amount int ) with ( 'connector' = 'print' ); insert into printSink select * from dataGenSOurce;
After the job is submitted, the job status changes to Running. You can perform the following operations of either method to view the output result: