【发布时间】:2021-06-07 23:04:43
【问题描述】:
我在 HDFS 中有一些两次分区的文件,其结构如下:
/user/hive/warehouse/datascience.db/simulations/datekey=20210506/coeff=0.5/data.parquet
/user/hive/warehouse/datascience.db/simulations/datekey=20210506/coeff=0.75/data.parquet
/user/hive/warehouse/datascience.db/simulations/datekey=20210506/coeff=1.0/data.parquet
/user/hive/warehouse/datascience.db/simulations/datekey=20210507/coeff=0.5/data.parquet
/user/hive/warehouse/datascience.db/simulations/datekey=20210507/coeff=0.75/data.parquet
/user/hive/warehouse/datascience.db/simulations/datekey=20210507/coeff=1.0/data.parquet
并希望尽可能优雅地将这些加载到配置单元表中。我知道这样的典型解决方案是首先将所有数据加载到非分区表中,然后使用提到的动态分区将所有数据传输到最终表 here
但是,我的文件在实际数据中没有 datekey 和 coeff 值,它只在文件名中,因为它是这样分区的。那么,当我将这些值加载到中间表中时,我将如何跟踪它们呢?
一种解决方法是对每个 coeff 值和 datekey 执行单独的 load data inpath 查询。这不需要中间表,但会很麻烦并且可能不是最佳的。
有没有更好的方法来做到这一点?
【问题讨论】:
-
你不能不做
insert into new_tab(a,b,part_col) select x,part_col,y from old_table吗?假设您的新表分区不同。
标签: hadoop hive hdfs hive-partitions hiveddl