04-data-mount-to-hive.md
1 # Mount LakeSoul Data to Hive Meta 2 3 <!-- 4 SPDX-FileCopyrightText: 2023 LakeSoul Contributors 5 6 SPDX-License-Identifier: Apache-2.0 7 --> 8 9 Since version 2.0, LakeSoul supports two functions: attaching the directory path after Compaction to the specified Hive table, specifying the same partition name as LakeSoul, and customizing the partition name. This function can facilitate downstream systems that can only support Hive to read LakeSoul data. It is more recommended to support Hive JDBC through Kyuubi, so that you can directly use Hive JDBC to call the Spark engine to access the LakeSoul table, including Merge on Read. 10 11 ## Keep the Same Partition Name as LakeSoul Range 12 The user can not add the hive partition name information, which is consistent with the LakeSoul partition name by default. 13 14 ```scala 15 import com.dmetasoul.lakesoul.tables.LakeSoulTable 16 val lakeSoulTable = LakeSoulTable.forName("lakesoul_test_table") 17 lakeSoulTable.compaction("date='2021-01-01'", "spark_catalog.default.hive_test_table") 18 ``` 19 20 ## Custom Hive Partition Name 21 You can also customize the hive partition name to standardize the use of data in the hive partition. 22 23 ```scala 24 import com.dmetasoul.lakesoul.tables.LakeSoulTable 25 val lakeSoulTable = LakeSoulTable.forName("lakesoul_test_table") 26 lakeSoulTable.compaction("date='2021-01-02'", "spark_catalog.default.hive_test_table", "date='20210102'") 27 ``` 28 29 **Note * * The function of attaching data to the hive meta needs to be used together with the compression function. Please refer to API: 6. Comparison for relevant data compression functions 30