我在 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
并希望尽可能优雅地将这些加载到蜂巢表中。我知道这样的典型解决方案是首先将所有数据加载到非分区表中,然后使用此处提到的动态分区将所有数据传输到最终表
但是,我的文件在实际数据中没有 datekey 和 coeff 值,它只在文件名中,因为它是这样分区的。那么,当我将这些值加载到中间表中时,我将如何跟踪它们呢?
一种解决方法是对每个 coeff 值和 datekey 进行单独的load data inpath
查询。这不需要中间表,但会很麻烦并且可能不是最佳的。
有没有更好的方法来做到这一点?