【问题标题】:splitting data into multiple tables in hive在 hive 中将数据拆分为多个表
【发布时间】:2014-07-15 11:35:38
【问题描述】:

我有一个包含 1 亿行的数据。我需要将其拆分为每个 1000 万行的表。这如何在 hive 中完成。

有效的sql查询为:

 select * from Customers where rownum>0 and rownum<=1000000  
 select * from Customers where rownum>1000000 and rownum<=2000000  

等等..

谢谢

【问题讨论】:

    标签: hive


    【解决方案1】:

    如果您使用的是最新版本,Hive 的 ROW_NUMBER 为 analytics function。

    否则,您可以执行以下操作:

    from (select Customers.*, rand() as r from Customers) t
    insert overwrite table Customers_sample1 select * where r < 0.1
    insert overwrite table Customers_sample2 select * where r >=0.1 and r < 0.2
    insert overwrite table Customers_sample3 select * where r >=0.2 and r < 0.3
    ...
    

    【讨论】:

      猜你喜欢
      • 2019-01-05
      • 1970-01-01
      • 2020-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-07
      相关资源
      最近更新 更多