forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
168 lines
17 KiB
HTML
168 lines
17 KiB
HTML
<a name="dli_08_15060"></a><a name="dli_08_15060"></a>
|
|
|
|
<h1 class="topictitle1">Print</h1>
|
|
<div id="body0000001784634313"><div class="section" id="dli_08_15060__dli_08_0256_en-us_topic_0132788972_section108631122164917"><h4 class="sectiontitle">Function</h4><p id="dli_08_15060__p661816320442">The Print connector is used to print output data to the error file or out file in the TaskManager, making it easier for you to view the result in code debugging.</p>
|
|
</div>
|
|
<div class="section" id="dli_08_15060__section1832471915404"><h4 class="sectiontitle">Prerequisites</h4><p id="dli_08_15060__p524095611227">None</p>
|
|
</div>
|
|
<div class="section" id="dli_08_15060__section16133159104212"><h4 class="sectiontitle">Caveats</h4><ul id="dli_08_15060__ul12805119131415"><li id="dli_08_15060__li1780591911414">The Print result table supports the following output formats:
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_15060__table4775325815" frame="border" border="1" rules="all"><thead align="left"><tr id="dli_08_15060__row671653205815"><th align="left" class="cellrowborder" valign="top" width="33.3033303330333%" id="mcps1.3.3.2.1.1.1.4.1.1"><p id="dli_08_15060__p274538582">Print</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="33.803380338033804%" id="mcps1.3.3.2.1.1.1.4.1.2"><p id="dli_08_15060__p6765314583">Condition 1</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="32.893289328932894%" id="mcps1.3.3.2.1.1.1.4.1.3"><p id="dli_08_15060__p188115355817">Condition 2</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_15060__row18195311581"><td class="cellrowborder" valign="top" width="33.3033303330333%" headers="mcps1.3.3.2.1.1.1.4.1.1 "><p id="dli_08_15060__p158553185815">Identifier:Task ID> Output data</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.803380338033804%" headers="mcps1.3.3.2.1.1.1.4.1.2 "><p id="dli_08_15060__p15875305820">A print identifier prefix must be provided. That is, you must specify <strong id="dli_08_15060__b61528282691730">print-identifier</strong> in the <strong id="dli_08_15060__b112769462791730">WITH</strong> parameter when creating the Print result table.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.893289328932894%" headers="mcps1.3.3.2.1.1.1.4.1.3 "><p id="dli_08_15060__p68165311584">parallelism > 1</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_15060__row6825395818"><td class="cellrowborder" valign="top" width="33.3033303330333%" headers="mcps1.3.3.2.1.1.1.4.1.1 "><p id="dli_08_15060__p1781853185820">Identifier> Output data</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.803380338033804%" headers="mcps1.3.3.2.1.1.1.4.1.2 "><p id="dli_08_15060__p18825317585">A print identifier prefix must be provided. That is, you must specify <strong id="dli_08_15060__b15515937991730">print-identifier</strong> in the <strong id="dli_08_15060__b167631798791730">WITH</strong> parameter when creating the Print result table.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.893289328932894%" headers="mcps1.3.3.2.1.1.1.4.1.3 "><p id="dli_08_15060__p5855311585">parallelism == 1</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_15060__row1081053165810"><td class="cellrowborder" valign="top" width="33.3033303330333%" headers="mcps1.3.3.2.1.1.1.4.1.1 "><p id="dli_08_15060__p12813538582">Task ID> Output data</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.803380338033804%" headers="mcps1.3.3.2.1.1.1.4.1.2 "><p id="dli_08_15060__p188553105818">A print identifier prefix is not needed. That is, you do not specify <strong id="dli_08_15060__b6052940391730">print-identifier</strong> in the <strong id="dli_08_15060__b10714912691730">WITH</strong> parameter when creating the Print result table.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.893289328932894%" headers="mcps1.3.3.2.1.1.1.4.1.3 "><p id="dli_08_15060__p98125311584">parallelism > 1</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_15060__row188253175816"><td class="cellrowborder" valign="top" width="33.3033303330333%" headers="mcps1.3.3.2.1.1.1.4.1.1 "><p id="dli_08_15060__p18853195816">Output data</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="33.803380338033804%" headers="mcps1.3.3.2.1.1.1.4.1.2 "><p id="dli_08_15060__p68145320580">A print identifier prefix is not needed. That is, you do not specify <strong id="dli_08_15060__b81645367991730">print-identifier</strong> in the <strong id="dli_08_15060__b55661595091730">WITH</strong> parameter when creating the Print result table.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="32.893289328932894%" headers="mcps1.3.3.2.1.1.1.4.1.3 "><p id="dli_08_15060__p1815532582">parallelism == 1</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</li></ul>
|
|
<ul id="dli_08_15060__ul21933142148"><li id="dli_08_15060__li13608118132418">When you create a Flink OpenSource SQL job, set <strong id="dli_08_15060__dli_08_15029_b163001353185217">Flink Version</strong> to <strong id="dli_08_15060__dli_08_15029_b1430115539523">1.15</strong> in the <strong id="dli_08_15060__dli_08_15029_b1030175315523">Running Parameters</strong> tab. Select <strong id="dli_08_15060__dli_08_15029_b430135325212">Save Job Log</strong>, and specify the OBS bucket for saving job logs.</li></ul>
|
|
</div>
|
|
<div class="section" id="dli_08_15060__dli_08_0256_en-us_topic_0132788972_section3126105364419"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="dli_08_15060__dli_08_0256_screen1461215294716"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
|
|
<span class="normal">2</span>
|
|
<span class="normal">3</span>
|
|
<span class="normal">4</span>
|
|
<span class="normal">5</span>
|
|
<span class="normal">6</span>
|
|
<span class="normal">7</span>
|
|
<span class="normal">8</span>
|
|
<span class="normal">9</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">create</span><span class="w"> </span><span class="k">table</span><span class="w"> </span><span class="n">printSink</span><span class="w"> </span><span class="p">(</span>
|
|
<span class="w"> </span><span class="n">attr_name</span><span class="w"> </span><span class="n">attr_type</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="p">(</span><span class="s1">','</span><span class="w"> </span><span class="n">attr_name</span><span class="w"> </span><span class="n">attr_type</span><span class="p">)</span><span class="w"> </span><span class="o">*</span><span class="w"> </span>
|
|
<span class="w"> </span><span class="p">(</span><span class="s1">','</span><span class="w"> </span><span class="k">PRIMARY</span><span class="w"> </span><span class="k">KEY</span><span class="w"> </span><span class="p">(</span><span class="n">attr_name</span><span class="p">,...)</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="n">ENFORCED</span><span class="p">)</span>
|
|
<span class="p">)</span><span class="w"> </span><span class="k">with</span><span class="w"> </span><span class="p">(</span>
|
|
<span class="w"> </span><span class="s1">'connector'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'print'</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="s1">'print-identifier'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span>
|
|
<span class="w"> </span><span class="s1">'standard-error'</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">''</span>
|
|
<span class="p">);</span>
|
|
</pre></div></td></tr></table></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_15060__dli_08_0256_section4299113491"><h4 class="sectiontitle">Parameter Description</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_15060__table11617424154613" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters</caption><thead align="left"><tr id="dli_08_15060__row146177242466"><th align="left" class="cellrowborder" valign="top" width="15.32%" id="mcps1.3.5.2.2.6.1.1"><p id="dli_08_15060__p1361712418461">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="9.09%" id="mcps1.3.5.2.2.6.1.2"><p id="dli_08_15060__p176171424114615">Mandatory</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="11.04%" id="mcps1.3.5.2.2.6.1.3"><p id="dli_08_15060__p20935421305">Default Value</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="11.72%" id="mcps1.3.5.2.2.6.1.4"><p id="dli_08_15060__p184921935103118">Data Type</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="52.83%" id="mcps1.3.5.2.2.6.1.5"><p id="dli_08_15060__p261712247467">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="dli_08_15060__row136171242461"><td class="cellrowborder" valign="top" width="15.32%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_15060__p992213916285">connector</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.09%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_15060__p169221598288">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.04%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_15060__p15153295324">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.72%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_15060__p94921935193112">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52.83%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_15060__p1492219917287">Connector to be used. Set this parameter to <strong id="dli_08_15060__b176686124191730">print</strong>.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_15060__row1961742414462"><td class="cellrowborder" valign="top" width="15.32%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_15060__p189227911283">print-identifier</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.09%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_15060__p119227912817">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.04%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_15060__p33541033210">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.72%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_15060__p94921935113119">String</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52.83%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_15060__p7867103732716">Message that identifies print and is prefixed to the output of the value.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_15060__row1761802415461"><td class="cellrowborder" valign="top" width="15.32%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_15060__p1092209122818">standard-error</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.09%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_15060__p149225917285">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.04%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_15060__p69364218305">false</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.72%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_15060__p249273518318">Boolean</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52.83%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_15060__p9635357112713">The value can be only <strong id="dli_08_15060__b9066911591730">true</strong> or <strong id="dli_08_15060__b115339857391730">false</strong>. The default value is <strong id="dli_08_15060__b186824500391730">false</strong>.</p>
|
|
<ul id="dli_08_15060__ul1450115619284"><li id="dli_08_15060__li12798014112819">If the value is <strong id="dli_08_15060__b101321449491730">true</strong>, data is output to the error file of the TaskManager.</li><li id="dli_08_15060__li850111672814">If the value is <strong id="dli_08_15060__b73817219791730">false</strong>, data is output to the <strong id="dli_08_15060__b212384971191730">out</strong> file of the TaskManager.</li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="dli_08_15060__row1222817343211"><td class="cellrowborder" valign="top" width="15.32%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_15060__p922919323215">sink.parallelism</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.09%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_15060__p122291636321">No</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.04%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_15060__p1622911318325">None</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="11.72%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_15060__p152291393213">Integer</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="52.83%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_15060__p7229838326">Defines the parallelism of the Print result table. By default, the parallelism is determined by the framework: using the same parallelism as the upstream chained operator.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_15060__section8515152835418"><h4 class="sectiontitle">Example</h4><p id="dli_08_15060__en-us_topic_0000001228095639_p133815267248">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.</p>
|
|
<pre class="screen" id="dli_08_15060__en-us_topic_0000001228095639_screen1990817895210">create table dataGenSource(
|
|
user_id string,
|
|
amount int
|
|
) with (
|
|
'connector' = 'datagen',
|
|
'rows-per-second' = '1', --Generates a piece of data per second.
|
|
'fields.user_id.kind' = 'random', --Specifies a random generator for the user_id field.
|
|
'fields.user_id.length' = '3' --Limits the length of user_id to 3.
|
|
);
|
|
|
|
create table printSink(
|
|
user_id string,
|
|
amount int
|
|
) with (
|
|
'connector' = 'print',
|
|
'print-identifier' = '', --Configure the data prefix.
|
|
'standard-error' = 'false', --Output data to the out file of TaskManager.
|
|
'sink.parallelism' = '2' --Configure the parallelism.
|
|
);
|
|
|
|
insert into printSink select * from dataGenSource;</pre>
|
|
<p id="dli_08_15060__en-us_topic_0000001228095639_p23018165418">After the job is submitted, the job status changes to <strong id="dli_08_15060__b5560312121915">Running</strong>. You can perform the following operations of either method to view the output result:</p>
|
|
<ul id="dli_08_15060__en-us_topic_0000001228095639_ul133191514102210"><li id="dli_08_15060__li98695310117">Method 1:<ol id="dli_08_15060__en-us_topic_0000001228095639_ol4711275385"><li id="dli_08_15060__en-us_topic_0000001228095639_li5612141010388">Log in to the DLI console. In the navigation pane, choose <strong id="dli_08_15060__b155241103091730">Job Management</strong> > <strong id="dli_08_15060__b34214635991730">Flink Jobs</strong>.</li><li id="dli_08_15060__en-us_topic_0000001228095639_li117110711383">Locate the row that contains the target Flink job, and choose <strong id="dli_08_15060__b159573800491730">More</strong> > <strong id="dli_08_15060__b95673311991730">FlinkUI</strong> in the <strong id="dli_08_15060__b133337553991730">Operation</strong> column.</li><li id="dli_08_15060__en-us_topic_0000001228095639_li07833554385">On the Flink UI, choose <strong id="dli_08_15060__b6588080891730">Task Managers</strong>, click the task name, and select <strong id="dli_08_15060__b120712619391730">Stdout</strong> to view job logs.</li></ol>
|
|
</li><li id="dli_08_15060__en-us_topic_0000001228095639_li341910155285">Method 2: If you select <strong id="dli_08_15060__b115096656491730">Save Job Log</strong> on the <strong id="dli_08_15060__b146792202991730">Running Parameters</strong> tab before submitting the job, perform the following operations:<ol id="dli_08_15060__en-us_topic_0000001228095639_ol864115198285"><li id="dli_08_15060__en-us_topic_0000001228095639_li10901621122819">Log in to the DLI console. In the navigation pane, choose <strong id="dli_08_15060__b77621659691730">Job Management</strong> > <strong id="dli_08_15060__b190189130891730">Flink Jobs</strong>.</li><li id="dli_08_15060__en-us_topic_0000001228095639_li1912163912282">Click the name of the corresponding Flink job, choose <strong id="dli_08_15060__b97048806891730">Run Log</strong>, click <strong id="dli_08_15060__b168853594991730">OBS Bucket</strong>, and locate the folder of the log you want to view according to the date.</li><li id="dli_08_15060__en-us_topic_0000001228095639_li0641191914285">Go to the folder of the date, find the folder whose name contains <strong id="dli_08_15060__b142432226891730">taskmanager</strong>, download the <strong id="dli_08_15060__b179895788291730">taskmanager.out</strong> file, and view result logs.</li></ol>
|
|
</li><li id="dli_08_15060__li189057247411">Method 3: If the queue is a new version, perform the following operations:<ol id="dli_08_15060__ol124888274615"><li id="dli_08_15060__li84886271565">Log in to the DLI console. In the navigation pane, choose <strong id="dli_08_15060__b165324902391730">Job Management</strong> > <strong id="dli_08_15060__b36623016691730">Flink Jobs</strong>.</li><li id="dli_08_15060__li56495333144">In the job list, click the name of your desired Flink job. On the displayed page, click the <strong id="dli_08_15060__b4768155815338">Logs</strong> tab.</li><li id="dli_08_15060__li13523646264">Select the corresponding TaskManager name from the drop-down list in the upper left corner and click the <strong id="dli_08_15060__b17186211364">taskmanager.out</strong> file to view its result log.</li></ol>
|
|
</li></ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_15027.html">Connectors</a></div>
|
|
</div>
|
|
</div>
|
|
|