doc-exports/docs/dli/sqlreference/dli_08_0399.html
Su, Xiaomeng 04d4597cf3 dli_sqlreference_0511_version
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>
2023-11-02 14:34:08 +00:00

155 lines
19 KiB
HTML

<a name="dli_08_0399"></a><a name="dli_08_0399"></a>
<h1 class="topictitle1">Print Result Table</h1>
<div id="body8662426"><div class="section" id="dli_08_0399__en-us_topic_0000001262495790_dli_08_0256_en-us_topic_0132788972_section108631122164917"><h4 class="sectiontitle">Function</h4><p id="dli_08_0399__en-us_topic_0000001262495790_p661816320442">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.</p>
</div>
<div class="section" id="dli_08_0399__en-us_topic_0000001262495790_section1832471915404"><h4 class="sectiontitle">Prerequisites</h4><p id="dli_08_0399__en-us_topic_0000001262495790_p524095611227">None</p>
</div>
<div class="section" id="dli_08_0399__en-us_topic_0000001262495790_section16133159104212"><h4 class="sectiontitle">Precautions</h4><ul id="dli_08_0399__en-us_topic_0000001262495790_ul12805119131415"><li id="dli_08_0399__en-us_topic_0000001262495790_li1780591911414">The Print result table supports the following output formats:
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0399__en-us_topic_0000001262495790_table4775325815" frame="border" border="1" rules="all"><thead align="left"><tr id="dli_08_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_p188115355817">Condition 2</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_08_0399__en-us_topic_0000001262495790_row18195311581"><td class="cellrowborder" valign="top" width="33.3033303330333%" headers="mcps1.3.3.2.1.1.1.4.1.1 "><p id="dli_08_0399__en-us_topic_0000001262495790_p158553185815">Identifier:Task ID&gt; 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_0399__en-us_topic_0000001262495790_p15875305820">A print identifier prefix must be provided. That is, you must specify <strong id="dli_08_0399__en-us_topic_0000001262495790_b15983428383">print-identifier</strong> in the <strong id="dli_08_0399__en-us_topic_0000001262495790_b17112424812">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_0399__en-us_topic_0000001262495790_p68165311584">parallelism &gt; 1</p>
</td>
</tr>
<tr id="dli_08_0399__en-us_topic_0000001262495790_row6825395818"><td class="cellrowborder" valign="top" width="33.3033303330333%" headers="mcps1.3.3.2.1.1.1.4.1.1 "><p id="dli_08_0399__en-us_topic_0000001262495790_p1781853185820">Identifier&gt; 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_0399__en-us_topic_0000001262495790_p18825317585">A print identifier prefix must be provided. That is, you must specify <strong id="dli_08_0399__en-us_topic_0000001262495790_b174391214171416">print-identifier</strong> in the <strong id="dli_08_0399__en-us_topic_0000001262495790_b154391114141412">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_0399__en-us_topic_0000001262495790_p5855311585">parallelism == 1</p>
</td>
</tr>
<tr id="dli_08_0399__en-us_topic_0000001262495790_row1081053165810"><td class="cellrowborder" valign="top" width="33.3033303330333%" headers="mcps1.3.3.2.1.1.1.4.1.1 "><p id="dli_08_0399__en-us_topic_0000001262495790_p12813538582">Task ID&gt; 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_0399__en-us_topic_0000001262495790_p188553105818">A print identifier prefix is not needed. That is, you do not specify <strong id="dli_08_0399__en-us_topic_0000001262495790_b1422334421420">print-identifier</strong> in the <strong id="dli_08_0399__en-us_topic_0000001262495790_b222444421413">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_0399__en-us_topic_0000001262495790_p98125311584">parallelism &gt; 1</p>
</td>
</tr>
<tr id="dli_08_0399__en-us_topic_0000001262495790_row188253175816"><td class="cellrowborder" valign="top" width="33.3033303330333%" headers="mcps1.3.3.2.1.1.1.4.1.1 "><p id="dli_08_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_p68145320580">A print identifier prefix is not needed. That is, you do not specify <strong id="dli_08_0399__en-us_topic_0000001262495790_b1835572231515">print-identifier</strong> in the <strong id="dli_08_0399__en-us_topic_0000001262495790_b335618229158">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_0399__en-us_topic_0000001262495790_p1815532582">parallelism == 1</p>
</td>
</tr>
</tbody>
</table>
</div>
</li></ul>
<ul id="dli_08_0399__en-us_topic_0000001262495790_ul21933142148"><li id="dli_08_0399__en-us_topic_0000001262495790_li2019471481413">When creating a Flink OpenSource SQL job, you need to set <strong id="dli_08_0399__en-us_topic_0000001262495790_b12575127101510">Flink Version</strong> to <strong id="dli_08_0399__en-us_topic_0000001262495790_b13582152771517">1.12</strong> on the <strong id="dli_08_0399__en-us_topic_0000001262495790_b558212276151">Running Parameters</strong> tab of the job editing page, select <strong id="dli_08_0399__en-us_topic_0000001262495790_b258362716154">Save Job Log</strong>, and set the OBS bucket for saving job logs.</li></ul>
</div>
<div class="section" id="dli_08_0399__en-us_topic_0000001262495790_dli_08_0256_en-us_topic_0132788972_section3126105364419"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="dli_08_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_dli_08_0256_section4299113491"><h4 class="sectiontitle">Parameters</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0399__en-us_topic_0000001262495790_table11617424154613" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="dli_08_0399__en-us_topic_0000001262495790_row146177242466"><th align="left" class="cellrowborder" valign="top" width="15.32%" id="mcps1.3.5.2.2.6.1.1"><p id="dli_08_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_p261712247467">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_08_0399__en-us_topic_0000001262495790_row136171242461"><td class="cellrowborder" valign="top" width="15.32%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_p1492219917287">Connector to be used. Set this parameter to <strong id="dli_08_0399__en-us_topic_0000001262495790_b78011313191614">print</strong>.</p>
</td>
</tr>
<tr id="dli_08_0399__en-us_topic_0000001262495790_row1961742414462"><td class="cellrowborder" valign="top" width="15.32%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_p7867103732716">Message that identifies print and is prefixed to the output of the value.</p>
</td>
</tr>
<tr id="dli_08_0399__en-us_topic_0000001262495790_row1761802415461"><td class="cellrowborder" valign="top" width="15.32%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_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_0399__en-us_topic_0000001262495790_p9635357112713">The value can be only <strong id="dli_08_0399__en-us_topic_0000001262495790_b9577164652120">true</strong> or <strong id="dli_08_0399__en-us_topic_0000001262495790_b17322448192116">false</strong>. The default value is <strong id="dli_08_0399__en-us_topic_0000001262495790_b14636654182114">false</strong>.</p>
<ul id="dli_08_0399__en-us_topic_0000001262495790_ul1450115619284"><li id="dli_08_0399__en-us_topic_0000001262495790_li12798014112819">If the value is <strong id="dli_08_0399__en-us_topic_0000001262495790_b65638183252">true</strong>, data is output to the error file of the TaskManager.</li><li id="dli_08_0399__en-us_topic_0000001262495790_li850111672814">If the value is <strong id="dli_08_0399__en-us_topic_0000001262495790_b118723112610">false</strong>, data is output to the <strong id="dli_08_0399__en-us_topic_0000001262495790_b282515717262">out</strong> file of the TaskManager.</li></ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_08_0399__en-us_topic_0000001262495790_section8515152835418"><h4 class="sectiontitle">Example</h4><p id="dli_08_0399__en-us_topic_0000001262495790_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>
<p id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_p4737175412255">When you create a job, set <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b3605178557">Flink Version</strong> to <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b96051275554">1.12</strong> on the <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b136058725520">Running Parameters</strong> tab. Select <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b160513715556">Save Job Log</strong>, and specify the OBS bucket for saving job logs.</p>
<pre class="screen" id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_screen1990817895210">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;</pre>
<p id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_p23018165418">After the job is submitted, the job status changes to <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b9421144185715">Running</strong>. You can perform the following operations of either method to view the output result:</p>
<ul id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_ul133191514102210"><li id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_li11970649381">Method 1:<ol id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_ol4711275385"><li id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_li5612141010388">Log in to the DLI console. In the navigation pane, choose <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b15413141218577">Job Management</strong> &gt; <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b74131112205713">Flink Jobs</strong>.</li><li id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_li117110711383">Locate the row that contains the target Flink job, and choose <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b16598325165916">More</strong> &gt; <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b1460482517595">FlinkUI</strong> in the <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b17604102511598">Operation</strong> column.</li><li id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_li07833554385">On the Flink UI, choose <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b11983732165913">Task Managers</strong>, click the task name, and select <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b6983932185919">Stdout</strong> to view job logs.</li></ol>
</li><li id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_li341910155285">Method 2: If you select <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b11174124265918">Save Job Log</strong> on the <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b21741542175917">Running Parameters</strong> tab before submitting the job, perform the following operations:<ol id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_ol864115198285"><li id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_li10901621122819">Log in to the DLI console. In the navigation pane, choose <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b1563785010595">Job Management</strong> &gt; <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b363795035917">Flink Jobs</strong>.</li><li id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_li1912163912282">Click the name of the corresponding Flink job, choose <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b7206356175919">Run Log</strong>, click <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b4206175619590">OBS Bucket</strong>, and locate the folder of the log you want to view according to the date.</li><li id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_li0641191914285">Go to the folder of the date, find the folder whose name contains <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b23814413013">taskmanager</strong>, download the <strong id="dli_08_0399__en-us_topic_0000001262495790_en-us_topic_0000001228095639_b33821241013">taskmanager.out</strong> file, and view result logs.</li></ol>
</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0391.html">Creating Result Tables</a></div>
</div>
</div>