Yang, Tong 6182f91ba8 MRS component operation guide_normal 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>
2022-12-09 14:55:21 +00:00

212 lines
17 KiB
HTML

<a name="mrs_01_24064"></a><a name="mrs_01_24064"></a>
<h1 class="topictitle1">Synchronizing Hudi Table Data to Hive</h1>
<div id="body0000001099070214"><p id="mrs_01_24064__p437215780">You can run <strong id="mrs_01_24064__b1699193493">run_hive_sync_tool.sh</strong> to synchronize data in the Hudi table to Hive.</p>
<p id="mrs_01_24064__p81519218509">For example, run the following command to synchronize the Hudi table in the <strong id="mrs_01_24064__b1695113573332">hdfs://hacluster/tmp/huditest/hudimor1_deltastreamer_partition</strong> directory on HDFS to the Hive table <strong id="mrs_01_24064__b1660745293315">table hive_sync_test3</strong> with <strong id="mrs_01_24064__b1178112324916">unite</strong>, <strong id="mrs_01_24064__b1617417341690">country</strong>, and <strong id="mrs_01_24064__b153194375910">state</strong> as partition keys:</p>
<p id="mrs_01_24064__p8398152015265"><strong id="mrs_01_24064__b14184172312620">run_hive_sync_tool.sh --partitioned-by unite,country,state --base-path hdfs://hacluster/tmp/huditest/hudimor1_deltastreamer_partition --table hive_sync_test3 --partition-value-extractor org.apache.hudi.hive.MultiPartKeysValueExtractor --support-timestamp</strong></p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="mrs_01_24064__table137667720218" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="mrs_01_24064__row5824197132117"><th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.5.1.1"><p id="mrs_01_24064__p1582412713218">Command</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="35%" id="mcps1.3.4.2.5.1.2"><p id="mrs_01_24064__p38243762111">Description</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="20%" id="mcps1.3.4.2.5.1.3"><p id="mrs_01_24064__p10824479218">Mandatory or Not (Yes or No)</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="25%" id="mcps1.3.4.2.5.1.4"><p id="mrs_01_24064__p138241719216">Default Value</p>
</th>
</tr>
</thead>
<tbody><tr id="mrs_01_24064__row148245712214"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p188241374214">--database</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p138247712219">Specifies the Hive database name.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p58243711211">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p8824779216">default</p>
</td>
</tr>
<tr id="mrs_01_24064__row482419710212"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p15824117142111">--table</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p482420715213">Specifies the Hive table name.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p1882417719216">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p168241573219">-</p>
</td>
</tr>
<tr id="mrs_01_24064__row0824157162118"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p2082413710217">--base-file-format</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p178249752116">Specifies the file format (<strong id="mrs_01_24064__b1468412113915">PARQUET</strong> or <strong id="mrs_01_24064__b198831514153916">HFILE</strong>).</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p782437192115">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p1182417182115">PARQUET</p>
</td>
</tr>
<tr id="mrs_01_24064__row1082415762110"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p782447172116">--user</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p1682447102115">Specifies the Hive username.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p18824178215">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p182412702113">-</p>
</td>
</tr>
<tr id="mrs_01_24064__row128246712112"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p7824207132112">--pass</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p188249712211">Specifies the Hive password.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p118241475215">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p1682418718218">-</p>
</td>
</tr>
<tr id="mrs_01_24064__row18242715213"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p7824175219">--jdbc-url</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p5824878216">Specifies the Hive JDBC connection URL.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p118244711213">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p18241877215">-</p>
</td>
</tr>
<tr id="mrs_01_24064__row18824137192117"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p082537152111">--base-path</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p482577102114">Specifies the storage path of the Hudi table to be synchronized.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p1382517710217">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p1582518717212">-</p>
</td>
</tr>
<tr id="mrs_01_24064__row482547112114"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p18251071216">--partitioned-by</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p168256710215">Specifies the partition key.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p7825107132113">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p482510712218">-</p>
</td>
</tr>
<tr id="mrs_01_24064__row682518714219"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p18257752119">--partition-value-extractor</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p2082512712219">Specifies the partition class. PartitionValueExtractor needs to be implemented. The partition value can be extracted from the HDFS path.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p282557132110">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p1982512712117">SlashEncodedDayPartitionValueExtractor</p>
</td>
</tr>
<tr id="mrs_01_24064__row482547132114"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p15825178216">--assume-date-partitioning</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p282515732110">Creates partitions in yyyy/mm/dd format to support backward compatibility.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p982517782119">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p1182547142116">false</p>
</td>
</tr>
<tr id="mrs_01_24064__row1182511712115"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p128255732119">--use-pre-apache-input-format</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p198253715218">Use InputFormat in the <strong id="mrs_01_24064__b642313317547">com.uber.hoodie</strong> package to replace the one in the <strong id="mrs_01_24064__b2279148125513">org.apache.hudi</strong> package. Do not use this command except for migrating projects from <strong id="mrs_01_24064__b1991113715111">com.uber.hoodie</strong> to <strong id="mrs_01_24064__b159126710115">org.apache.hudi</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p882510722110">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p8825373212">false</p>
</td>
</tr>
<tr id="mrs_01_24064__row12825127112119"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p5825177162110">--use-jdbc</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p68259711213">Uses Hive JDBC connection.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p982577132110">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p118251718214">true</p>
</td>
</tr>
<tr id="mrs_01_24064__row8825472215"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p58251276213">--auto-create-database</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p682517719216">Specifies whether to automatically create a Hive database.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p5825197202110">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p158251078214">true</p>
</td>
</tr>
<tr id="mrs_01_24064__row198252742117"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p1782518722112">--skip-ro-suffix</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p1545395635918">Specifies whether to skip the read-optimized view with the <strong id="mrs_01_24064__b1981953217408">_ro</strong> suffix during registration.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p682587172115">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p28259719215">false</p>
</td>
</tr>
<tr id="mrs_01_24064__row1382557122117"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p18825197202120">--use-file-listing-from-metadata</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p1782597132119">Specifies whether to obtain the file list from the Hudi metadata.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p1782510712116">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p88251770216">false</p>
</td>
</tr>
<tr id="mrs_01_24064__row082518772116"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p18825137122110">--verify-metadata-file-listing</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p123401051211">Specifies whether to verify the file list in the Hudi metadata based on the file system.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p582597152114">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p2082515717212">false</p>
</td>
</tr>
<tr id="mrs_01_24064__row208256762112"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p1882513722114">--help/-h</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p108251477211">Specifies whether to display help information.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p882519762110">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p48251876213">false</p>
</td>
</tr>
<tr id="mrs_01_24064__row198256716219"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p1782510711216">--support-timestamp</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p15322401934">Specifies whether to convert <strong id="mrs_01_24064__b174431039191120">TIMESTAMP_MICROS</strong> of INT64 to Hive timestamp.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p1382510717211">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p882515792120">false</p>
</td>
</tr>
<tr id="mrs_01_24064__row1582547112111"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p18825127142113">--decode-partition</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p882557192111">Specifies whether to decode the partition value if the partition is encoded during the write process.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p182507182116">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p482516792114">false</p>
</td>
</tr>
<tr id="mrs_01_24064__row5120112822413"><td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.1 "><p id="mrs_01_24064__p18120182862414">--batch-sync-num</p>
</td>
<td class="cellrowborder" valign="top" width="35%" headers="mcps1.3.4.2.5.1.2 "><p id="mrs_01_24064__p612110287241">Specifies the number of Hive partitions to be synchronized in each batch.</p>
</td>
<td class="cellrowborder" valign="top" width="20%" headers="mcps1.3.4.2.5.1.3 "><p id="mrs_01_24064__p1712172816245">No</p>
</td>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.3.4.2.5.1.4 "><p id="mrs_01_24064__p17121102822410">1000</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="mrs_01_24064__note161188557234"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_24064__p1114218742411">During Hive synchronization, if the table does not exist, an external table is created and partitions are added. If the table exists, check whether table schemas are different. If they are different, replace the table. Check whether new partitions exist. If new partitions exist, partitions are added accordingly.</p>
<p id="mrs_01_24064__p514212772411">Therefore, there are the following restrictions when Hive synchronization is used:</p>
<ul id="mrs_01_24064__ul1231133918281"><li id="mrs_01_24064__li52311839112820">Fields can only be added to the schema and cannot be modified or deleted.</li><li id="mrs_01_24064__li723110395286">Partition directories can only be added but cannot be deleted.</li><li id="mrs_01_24064__li17231203919281"><strong id="mrs_01_24064__b1714656165711">Overwrite</strong> can only overwrite the Hudi table. The Hive table cannot be overwritten synchronously.</li><li id="mrs_01_24064__li162311639202819">Do not use the timestamp type as the partition column when synchronizing a Hudi table to Hive.</li><li id="mrs_01_24064__li6579336191814">When this script is used for synchronization, JDBC must be used for security purposes. That is, <strong id="mrs_01_24064__b209621053164719">--use-jdbc</strong> must be set to <strong id="mrs_01_24064__b883761114818">true</strong>.</li></ul>
</div></div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_24034.html">Write</a></div>
</div>
</div>