forked from docs/doc-exports
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>
81 lines
9.6 KiB
HTML
81 lines
9.6 KiB
HTML
<a name="mrs_01_24177"></a><a name="mrs_01_24177"></a>
|
|
|
|
<h1 class="topictitle1">ClickHouse Output</h1>
|
|
<div id="body32001227"><div class="section" id="mrs_01_24177__en-us_topic_0000001173631402_sa4409d226a45452d9737679221639361"><h4 class="sectiontitle">Overview</h4><p id="mrs_01_24177__en-us_topic_0000001173631402_a0311f7deda81412a8600259569430216">The <span class="parmname" id="mrs_01_24177__en-us_topic_0000001173631402_parmname138981053297"><b>ClickHouse Output</b></span> operator exports existing fields to specified columns of a ClickHouse table.</p>
|
|
</div>
|
|
<div class="section" id="mrs_01_24177__en-us_topic_0000001173631402_s5715fa96c64f454ea8a9e5e65a2164df"><h4 class="sectiontitle">Input and Output</h4><ul id="mrs_01_24177__en-us_topic_0000001173631402_ua633b7c4ae8543e6af4e377af4c7a4e7"><li id="mrs_01_24177__en-us_topic_0000001173631402_l37c70e79435b46229cbcdc2923e5b3e6">Input: fields to be exported</li><li id="mrs_01_24177__en-us_topic_0000001173631402_l8284b943ec814b9b988d23a113ff8b61">Output: ClickHouse table</li></ul>
|
|
</div>
|
|
<div class="section" id="mrs_01_24177__en-us_topic_0000001173631402_s89e855f5dcc84e469d4829e05988d9aa"><h4 class="sectiontitle">Parameters</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_24177__en-us_topic_0000001173631402_t27da1d11197f4150a4317a5dc555ca35" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Operator parameters</caption><thead align="left"><tr id="mrs_01_24177__en-us_topic_0000001173631402_r001a62a2acd04a409136327382ca44e5"><th align="left" class="cellrowborder" valign="top" width="18.389999999999997%" id="mcps1.3.3.2.2.6.1.1"><p id="mrs_01_24177__en-us_topic_0000001173631402_aae1e36d735b640f388aa8ee16bc5da3f">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="54.709999999999994%" id="mcps1.3.3.2.2.6.1.2"><p id="mrs_01_24177__en-us_topic_0000001173631402_ad7d1923bca974c47a2abd4b22c03d1ca">Description</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="7.519999999999999%" id="mcps1.3.3.2.2.6.1.3"><p id="mrs_01_24177__en-us_topic_0000001173631402_a4d8f7cbd8af644a8b1cc86618ae4432a">Type</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="9.689999999999998%" id="mcps1.3.3.2.2.6.1.4"><p id="mrs_01_24177__en-us_topic_0000001173631402_a7bbfea69f3654a9482e6ab4db8c8d4c3">Mandatory</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="9.689999999999998%" id="mcps1.3.3.2.2.6.1.5"><p id="mrs_01_24177__en-us_topic_0000001173631402_a7cf75b8014cc4f38bd5a759e9178da08">Default Value</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="mrs_01_24177__en-us_topic_0000001173631402_r1bd190003e584fd084ba1c244afdffa1"><td class="cellrowborder" valign="top" width="18.389999999999997%" headers="mcps1.3.3.2.2.6.1.1 "><p id="mrs_01_24177__en-us_topic_0000001173631402_aacd44482cbde45e59fa9b431c427f8e2">ClickHouse database name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="54.709999999999994%" headers="mcps1.3.3.2.2.6.1.2 "><p id="mrs_01_24177__en-us_topic_0000001173631402_aa153fac4cecc4cf0bd1f45d0e5e57c82">Database where the ClickHouse table is located.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="7.519999999999999%" headers="mcps1.3.3.2.2.6.1.3 "><p id="mrs_01_24177__en-us_topic_0000001173631402_ac159d691d73049b98360fa0ab8625b59">string</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.689999999999998%" headers="mcps1.3.3.2.2.6.1.4 "><p id="mrs_01_24177__en-us_topic_0000001173631402_a40291d0d94cb49f489e5fd6841e3dbac">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.689999999999998%" headers="mcps1.3.3.2.2.6.1.5 "><p id="mrs_01_24177__en-us_topic_0000001173631402_a0aaedb19e52e4841b581650973bc1b71">default</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_24177__en-us_topic_0000001173631402_r6acdc088c0814fe19c0c7587d3c032de"><td class="cellrowborder" valign="top" width="18.389999999999997%" headers="mcps1.3.3.2.2.6.1.1 "><p id="mrs_01_24177__en-us_topic_0000001173631402_aa0f141bbcb3d4c558ea13714e9819b12">ClickHouse table name</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="54.709999999999994%" headers="mcps1.3.3.2.2.6.1.2 "><p id="mrs_01_24177__en-us_topic_0000001173631402_a911ef3e9543448a5bd19055cb53d3684">Name of the ClickHouse table to which data is written.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="7.519999999999999%" headers="mcps1.3.3.2.2.6.1.3 "><p id="mrs_01_24177__en-us_topic_0000001173631402_a1d4cd202431c42bab5185e946cd736f9">string</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.689999999999998%" headers="mcps1.3.3.2.2.6.1.4 "><p id="mrs_01_24177__en-us_topic_0000001173631402_a5456744ba89c4e8a90bbc8d0f66cf9d8">Yes</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="9.689999999999998%" headers="mcps1.3.3.2.2.6.1.5 "><p id="mrs_01_24177__en-us_topic_0000001173631402_a5305c7dacb444dd9a52424627fe8f2c4">None</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="mrs_01_24177__en-us_topic_0000001173631402_s75be7fbf35384e92b0b5ef793530127d"><h4 class="sectiontitle">Data Processing Rule</h4><p id="mrs_01_24177__en-us_topic_0000001173631402_p192820486313">The field values are exported to the ClickHouse table.</p>
|
|
</div>
|
|
<div class="section" id="mrs_01_24177__en-us_topic_0000001173631402_s8090f65807044fecb01ff0ab351ff75f"><h4 class="sectiontitle">Example</h4><p id="mrs_01_24177__en-us_topic_0000001173631402_aa8b84b731b674d73b6dfe3728ad5eecf">Use the <span class="parmname" id="mrs_01_24177__en-us_topic_0000001173631402_parmname198071700332"><b>CSV File Input</b></span> operator to generate 12 fields.</p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_a8d128370d93f46719f1572fce08aa71a">The following figure shows the source file.</p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p1393617315312"><span><img id="mrs_01_24177__en-us_topic_0000001173631402_image2039419278169" src="en-us_image_0000001349059881.png"></span></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p6564144725415">Run the following statements to create a ClickHouse table:</p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p1968213578186"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b693719119336">CREATE TABLE IF NOT EXISTS testck4 ON CLUSTER default_cluster(</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p16682175719184"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b193918117337">a Int32,</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p86829575182"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b14940171193313">b VARCHAR(100) NOT NULL,</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p1468216575182"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b4941191110339">c char(100),</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p268215761815"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b0942611203314">d DateTime,</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p1868265712184"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b13943151110334">e DateTime,</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p468218571182"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b149441711123312">f DateTime,</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p36825579188"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b1694414112335">g smallint,</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p166821757141816"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b694581143319">h bigint,</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p1682105761817"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b1594681112336">l Float32,</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p76821457111816"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b159461611123315">j Float64,</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p9682145714186"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b494761173317">k decimal(10,2),</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p1568295712187"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b594811153318">m boolean</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p9682257131813"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b994813111331">)</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p136827578183"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b189496113335">ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/default/testck4', '{replica}')</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p968217579188"><strong id="mrs_01_24177__en-us_topic_0000001173631402_b094981115339">PARTITION BY toYYYYMM(d)ORDER BY a;</strong></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_adca00551e87c470089c58545b2df24e2">Configure the <span class="parmname" id="mrs_01_24177__en-us_topic_0000001173631402_parmname243412343345"><b>ClickHouse Output</b></span> operator, as shown in the following figure.</p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p894120317319"><span><img id="mrs_01_24177__en-us_topic_0000001173631402_image176441216202" src="en-us_image_0000001349259329.png"></span></p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_abac011b6bf374055987f1bad8db9ded2">After the job execution is complete, view the data in the <strong id="mrs_01_24177__en-us_topic_0000001173631402_b126928543518">testck4</strong> table.</p>
|
|
<p id="mrs_01_24177__en-us_topic_0000001173631402_p1194219333118"><span><img id="mrs_01_24177__en-us_topic_0000001173631402_image77198222118" src="en-us_image_0000001349139745.png"></span></p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_1145.html">Output Operators</a></div>
|
|
</div>
|
|
</div>
|
|
|