spark向parquet/orc文件添加元数据

ttisahbt  于 2021-05-29  发布在  Hadoop
关注(0)|答案(0)|浏览(327)

每天,我需要为各种用例总结客户的活动。为了保持/不覆盖,我确保每次写入parquet(按日期分区)时,都会删除为此日期存储的任何以前的数据。但是,对于某些用例,我在执行上述操作时遇到了问题。
我想为客户存储每小时的活动
我想为每个客户每分钟存储活动
我想把它们都存储在同一个分区中。
示例代码

def delete_and_write(file_location):
      #1. if file_location exists delete
      #2. Write below
      df.repartition(1)
        .write.partitionBy("date")
        .save(file_location, format=file_format, mode='append', header='true')

我想做如下事情

def delete_and_write():
    #1. If file with specific meta data info exists delete
    #2. Write data with meta data such 1 hour window or so

因此,基本上不删除文件(如果它位于某个位置),我只想删除文件中包含特定信息/元数据的部分。这可能吗?例如,如果我在1小时内编写客户活动,并且此信息已经存在,我只想删除此信息,而不是删除文件位置中的所有内容。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题