Yang, Tong 3f5759eed2 MRS comp-lts 2.0.38.SP20 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Yang, Tong <yangtong2@huawei.com>
Co-committed-by: Yang, Tong <yangtong2@huawei.com>
2023-01-19 17:08:45 +00:00

62 lines
10 KiB
HTML

<a name="mrs_01_1124"></a><a name="mrs_01_1124"></a>
<h1 class="topictitle1">Table Input</h1>
<div id="body8662426"><div class="section" id="mrs_01_1124__en-us_topic_0000001219351277_s72eb6d86c4534f6d9bdee749562e800b"><h4 class="sectiontitle">Overview</h4><p id="mrs_01_1124__en-us_topic_0000001219351277_a5234bf0557ba49b79c762186ae44e97d"><span class="parmname" id="mrs_01_1124__en-us_topic_0000001219351277_p2b06be074e7a4857846e86ea198d590c"><b>Table Input</b></span> operator converts specified columns in a relational database table into input fields of the same quantity.</p>
</div>
<div class="section" id="mrs_01_1124__en-us_topic_0000001219351277_sae1dcecce1214ac0ade376f87f26f2c9"><h4 class="sectiontitle">Input and Output</h4><ul id="mrs_01_1124__en-us_topic_0000001219351277_u734d2b56a335468ea4bef876653daece"><li id="mrs_01_1124__en-us_topic_0000001219351277_l9814f5dbc0da48609fe6439572ae27bc">Input: table columns</li><li id="mrs_01_1124__en-us_topic_0000001219351277_le87b2c14893947068b2484324b030cd5">Output: fields</li></ul>
</div>
<div class="section" id="mrs_01_1124__en-us_topic_0000001219351277_sa97761504e294cb5bc1faa310182f3f2"><h4 class="sectiontitle">Parameter Description</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_1124__en-us_topic_0000001219351277_tcfc409afe0524a898d33b75fcee8a2b6" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Operator parameters description</caption><thead align="left"><tr id="mrs_01_1124__en-us_topic_0000001219351277_rcea480f149cd40aa863f46532f2c6901"><th align="left" class="cellrowborder" valign="top" width="18.37%" id="mcps1.3.3.2.2.6.1.1"><p id="mrs_01_1124__en-us_topic_0000001219351277_afc533541eff84f03968b53332f72b114">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="54.730000000000004%" id="mcps1.3.3.2.2.6.1.2"><p id="mrs_01_1124__en-us_topic_0000001219351277_a22ecf149f77344269665cd5f5538b151">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="7.5200000000000005%" id="mcps1.3.3.2.2.6.1.3"><p id="mrs_01_1124__en-us_topic_0000001219351277_a719280a8edf744588df28629ad6dd827">Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="9.69%" id="mcps1.3.3.2.2.6.1.4"><p id="mrs_01_1124__en-us_topic_0000001219351277_ad6a0364608ad49efa093750525f2bb29">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="9.69%" id="mcps1.3.3.2.2.6.1.5"><p id="mrs_01_1124__en-us_topic_0000001219351277_ae85b6c7d6de042329277d638bb3b0bbc">Default Value</p>
</th>
</tr>
</thead>
<tbody><tr id="mrs_01_1124__en-us_topic_0000001219351277_r5656b925dbbb402dbae514198dd09c88"><td class="cellrowborder" valign="top" width="18.37%" headers="mcps1.3.3.2.2.6.1.1 "><p id="mrs_01_1124__en-us_topic_0000001219351277_a519c3e10574d4783932d91b1298498bb">Input fields</p>
</td>
<td class="cellrowborder" valign="top" width="54.730000000000004%" headers="mcps1.3.3.2.2.6.1.2 "><p id="mrs_01_1124__en-us_topic_0000001219351277_a2aaf738c1e09403da21613ad2638d463">Information about relational database input fields:</p>
<ul id="mrs_01_1124__en-us_topic_0000001219351277_u7dba4e18efb24b789f90d39d0830e8ad"><li id="mrs_01_1124__en-us_topic_0000001219351277_l0d9d4910c45f4d9c917a351c8029f556"><strong id="mrs_01_1124__en-us_topic_0000001219351277_b1357817354159">position</strong>: position of input fields</li><li id="mrs_01_1124__en-us_topic_0000001219351277_l83062c5e333d4d0184e189da3649bc17"><strong id="mrs_01_1124__en-us_topic_0000001219351277_b7220838181519">field name</strong>: input field name</li><li id="mrs_01_1124__en-us_topic_0000001219351277_ld318e482a73b4b6a80861e43f225a43f"><strong id="mrs_01_1124__en-us_topic_0000001219351277_b205891740111515">type</strong>: field type</li><li id="mrs_01_1124__en-us_topic_0000001219351277_lf571761d37dc423c979658535b547510">length: Field value length. If the actual field value is excessively long, the value is cut based on the configured length. When <span class="parmname" id="mrs_01_1124__en-us_topic_0000001219351277_pe51996fd973b464796458c38612626bc"><b>type</b></span> is set to <span class="parmvalue" id="mrs_01_1124__en-us_topic_0000001219351277_p8a39b64eb73540deafdb9cc98ba02d72"><b>CHAR</b></span>, spaces are added to the field value for supplement if the actual field value length is less than the configured length. When <span class="parmname" id="mrs_01_1124__en-us_topic_0000001219351277_paae372f24a9442098fd466f3f9a5bbbd"><b>type</b></span> is set to <span class="parmvalue" id="mrs_01_1124__en-us_topic_0000001219351277_p0806c30f24f142299000ccca76772318"><b>VARCHAR</b></span>, no space is added to the field value for supplement if the actual field value length is less than the configured length.</li></ul>
</td>
<td class="cellrowborder" valign="top" width="7.5200000000000005%" headers="mcps1.3.3.2.2.6.1.3 "><p id="mrs_01_1124__en-us_topic_0000001219351277_aafd8c412088549a384800b97846efcb7">map</p>
</td>
<td class="cellrowborder" valign="top" width="9.69%" headers="mcps1.3.3.2.2.6.1.4 "><p id="mrs_01_1124__en-us_topic_0000001219351277_ad56a05291be24badb4757e6e0f6f75ab">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.69%" headers="mcps1.3.3.2.2.6.1.5 "><p id="mrs_01_1124__en-us_topic_0000001219351277_a4bb841356ab549a7bb68413fd94c17e0">None</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="mrs_01_1124__en-us_topic_0000001219351277_s7d2a08e39de14578b27a92801ee5181d"><h4 class="sectiontitle">Data Processing Rule</h4><ul id="mrs_01_1124__en-us_topic_0000001219351277_ud8a5f5012382430983be945b440a7ad8"><li id="mrs_01_1124__en-us_topic_0000001219351277_l91eddd71edbd460cbd690bf8d6b7d775">Fields are generated in a specified order. Table columns to be converted are specified by <span class="parmname" id="mrs_01_1124__en-us_topic_0000001219351277_p18035d9d8ba64093ae52e4cf00e2bc9d"><b>From</b></span> in step 2 of job configuration. If <span class="parmname" id="mrs_01_1124__en-us_topic_0000001219351277_pa9177a54276c4c7ca59fe441902e3a1c"><b>Table column names</b></span> is set, the value is the table columns to be converted; if <span class="parmname" id="mrs_01_1124__en-us_topic_0000001219351277_p6ab0dfafe0c74224b169192701e2ec1a"><b>Table column names</b></span> is not set, the table columns to be converted are all table columns in the table by default or the columns specified by the query conditions set by <span class="parmname" id="mrs_01_1124__en-us_topic_0000001219351277_peca14353a6e54f3485379f1ef9576563"><b>Table SQL statement</b></span>.</li><li id="mrs_01_1124__en-us_topic_0000001219351277_lec8752858fdf4422acfb0a15c91fcc1f">The number of input fields cannot be greater than number of specified columns; otherwise, all data becomes dirty data.</li><li id="mrs_01_1124__en-us_topic_0000001219351277_l01d8e836db054694953c73a990fd366c">If the field value does not match the actual type, the data in the line will become dirty data.</li></ul>
</div>
<div class="section" id="mrs_01_1124__en-us_topic_0000001219351277_s3b88d13bbc1243b78138b5c249ae4288"><h4 class="sectiontitle">Example</h4><p id="mrs_01_1124__en-us_topic_0000001219351277_aad7b2fd919de47c096b35b347c6027c6">Use SQL Server 2014 as an example. Run the following command to create a <strong id="mrs_01_1124__en-us_topic_0000001219351277_b74716716524">test</strong> table:</p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_af1a8b8576a764f9a89900046aed9f638"><strong id="mrs_01_1124__en-us_topic_0000001219351277_ac4358b767f2840f991b427932760c93e">create table test (id int, name text, value text);</strong></p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_adf77571b77c742baa3237c178eaf1975">Insert three data lines to the test table:</p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_a53af1460a4614018b03158567f10390b"><strong id="mrs_01_1124__en-us_topic_0000001219351277_a35d62a3d769b41a39b58c3d91eb4a1a5">insert into test values (1,'zhangshan','zhang');</strong></p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_aa61d6cb1092c4b968c55b0d051855e90"><strong id="mrs_01_1124__en-us_topic_0000001219351277_a6a81069834ba4baab27df83eaeaf187c">insert into test values (2,'lisi','li');</strong></p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_ab522e5c29cee4a43a10a533c1bfe4852"><strong id="mrs_01_1124__en-us_topic_0000001219351277_a167a0a43bf85407997f5e67b4584a416">insert into test values (3,'wangwu','wang');</strong></p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_aa86648951d374285881841c972fdfdf9">Query the table:</p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_ab789feeeebf94c4da1e6c9eb4722f919"><span><img id="mrs_01_1124__en-us_topic_0000001219351277_i900934d5b18b4d36bc457d06a65de705" src="en-us_image_0000001348740137.jpg"></span></p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_a9bcfa33291a744d8974ad3d2c82957bb">Configure the <span class="parmname" id="mrs_01_1124__en-us_topic_0000001219351277_parmname628410184521"><b>Table Input</b></span> operator to generate the following fields:</p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_ad3119985aeb145acbd700945d76b0a1e">After the data connector is set, click <span class="menucascade" id="mrs_01_1124__en-us_topic_0000001219351277_menucascade22465293521"><b><span class="uicontrol" id="mrs_01_1124__en-us_topic_0000001219351277_uicontrol524622955214">Automatic Identification</span></b></span>. The system will automatically read fields in the database and select required fields for adding. You only need to optimize or modify the fields manually based on service scenarios.</p>
<div class="note" id="mrs_01_1124__en-us_topic_0000001219351277_n76cc5e0e3879400c99e29afe3403562c"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_1124__en-us_topic_0000001219351277_a6a3dd12d7a234187a5a2384f49e23a9e">Performing this operation will overwrite existing data in the table.</p>
</div></div>
<p id="mrs_01_1124__en-us_topic_0000001219351277_a12414aa70b9f4430a756891feb669c61"><span><img id="mrs_01_1124__en-us_topic_0000001219351277_i172154a2a802493abafbaa7bf965a341" src="en-us_image_0000001349259405.png"></span></p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_ab60770197beb40be9d22fb5391fd6861">Configure the output operator to output data to HDFS/OBS. The result is as follows:</p>
<p id="mrs_01_1124__en-us_topic_0000001219351277_a6b7890ef2501423891be0f44269d83af"><span><img id="mrs_01_1124__en-us_topic_0000001219351277_ibedc6e13eefc4196861ac2aa12d5cd75" src="en-us_image_0000001349139825.jpg"></span></p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_1121.html">Input Operators</a></div>
</div>
</div>