forked from docs/doc-exports
Reviewed-by: Kacur, Michal <michal.kacur@t-systems.com> Co-authored-by: Yang, Tong <yangtong2@huawei.com> Co-committed-by: Yang, Tong <yangtong2@huawei.com>
61 lines
6.5 KiB
HTML
61 lines
6.5 KiB
HTML
<a name="mrs_01_24273"></a><a name="mrs_01_24273"></a>
|
|
|
|
<h1 class="topictitle1">INSERT INTO</h1>
|
|
<div id="body8662426"><div class="section" id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_s3635a0acb90b4993bd3ec49d72d184b2"><h4 class="sectiontitle">Function</h4><p id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_a7c198bf2c3ac40b08c49397d79368b0e">This command is used to insert the output of the <strong id="mrs_01_24273__en-us_topic_0000001173789382_b0805141363411">SELECT</strong> statement to a Hudi table.</p>
|
|
</div>
|
|
<div class="section" id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_s98d94c476c89464283380c169a39c3db"><h4 class="sectiontitle">Syntax</h4><p id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_a04c70312121e425d972d400525860f0b"><strong id="mrs_01_24273__en-us_topic_0000001173789382_b18325124154219">INSERT INTO</strong><em id="mrs_01_24273__en-us_topic_0000001173789382_i292610444420"> tableIndentifier select query;</em></p>
|
|
</div>
|
|
<div class="section" id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_sbe8fcdf864854703a0baa12e58c48821"><h4 class="sectiontitle">Parameter Description</h4>
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_t5be4c9a0e84a470c83ccef495498b366" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters</caption><thead align="left"><tr id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_r64ddb93f079344a8b87ad9ed751070ea"><th align="left" class="cellrowborder" valign="top" width="23.68%" id="mcps1.3.3.2.2.3.1.1"><p id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_aea60f327d33f4b879bb9a6f9526f4be9"><strong id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_a6fe8087d62e94e58a68e3490daa42437">Parameter</strong></p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="76.32%" id="mcps1.3.3.2.2.3.1.2"><p id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_aef70568549f840e59d0ff2e8888670e3"><strong id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_a17c5a2e2bdf54acdae17608a4ae2d192">Description</strong></p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_rc8314c90829b48509b421a7f14c2f54b"><td class="cellrowborder" valign="top" width="23.68%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_a234e6b2a720445778d4b07df52d737cd">tableIndentifier</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="76.32%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_a7ef19cdd66af46f0bee9be1785d45d61">Name of the Hudi table.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_r63d4d2ba87054461a5ed6e7e7a35ea93"><td class="cellrowborder" valign="top" width="23.68%" headers="mcps1.3.3.2.2.3.1.1 "><p id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_afa6af8dbad144471a00645e139a6d203">select query</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="76.32%" headers="mcps1.3.3.2.2.3.1.2 "><p id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_af0b7e6dfb2b94576840eaf41dfa3bc8e">SELECT statement.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_s6025d975533d475d8af0cfa213d22c18"><h4 class="sectiontitle">Precautions</h4><ul id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_u9ef5cd8074bb4d5aa999ddd3e6c5e76e"><li id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_la4acf75df3ac4d0599dc607651641f21">Insert mode: Hudi supports three insert modes for tables with primary keys. You can set a parameter to specify the insert mode. The default value is <strong id="mrs_01_24273__en-us_topic_0000001173789382_b524873952113">upsert</strong>.<ol id="mrs_01_24273__en-us_topic_0000001173789382_ol85073410431"><li id="mrs_01_24273__en-us_topic_0000001173789382_li165071424315">In strict mode, the INSERT statement retains the primary key constraint of COW tables and is not allowed to insert duplicate records. If a record already exists during data insertion, HoodieDuplicateKeyException is thrown for COW tables. For MOR tables, the behavior in this mode is the same as that in upsert mode.</li><li id="mrs_01_24273__en-us_topic_0000001173789382_li10507743436">In non-strict mode, records are inserted to primary key tables.</li><li id="mrs_01_24273__en-us_topic_0000001173789382_li175074484312">In upsert mode, duplicate values in the primary key table are updated.</li></ol>
|
|
</li><li id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_l21ff843cee064c829db3389cd4e3f121">You can set <strong id="mrs_01_24273__en-us_topic_0000001173789382_b56161218257">hoodie.sql.bulk.insert.enable</strong> to <strong id="mrs_01_24273__en-us_topic_0000001173789382_b3389371253">true</strong> to enable the bulk insert statement as the write mode of the insert statement. Bulkinsert cannot be performed on the primary key table.</li></ul>
|
|
</div>
|
|
<div class="section" id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_s5774072650ef43f4acf8b5bf8a6b75ea"><h4 class="sectiontitle">Examples</h4><pre class="screen" id="mrs_01_24273__en-us_topic_0000001173789382_screen96174332445">insert into h0 select 1, 'a1', 20;
|
|
|
|
-- insert static partition
|
|
insert into h_p0 partition(dt = '2021-01-02') select 1, 'a1';
|
|
|
|
-- insert dynamic partition
|
|
insert into h_p0 select 1, 'a1', dt;
|
|
|
|
-- insert dynamic partition
|
|
insert into h_p1 select 1 as id, 'a1', '2021-01-03' as dt, '19' as hh;
|
|
|
|
-- insert overwrite table
|
|
insert overwrite table h0 select 1, 'a1', 20;
|
|
|
|
-- insert overwrite table with static partition
|
|
insert overwrite h_p0 partition(dt = '2021-01-02') select 1, 'a1';
|
|
|
|
-- insert overwrite table with dynamic partition
|
|
insert overwrite table h_p1 select 2 as id, 'a2', '2021-01-03' as dt, '19' as hh;</pre>
|
|
</div>
|
|
<div class="section" id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_s089e7b6ebc3a401c93534dbe58a8ed83"><h4 class="sectiontitle">System Response</h4><p id="mrs_01_24273__en-us_topic_0000001173789382_en-us_topic_0265792800_abfe2a72f74b942ae8a2f3a2a73926ff7">You can view the result in driver logs.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_24272.html">Hudi DML</a></div>
|
|
</div>
|
|
</div>
|
|
|