hive如何去掉重复数据,显示第一条

hive如何去掉重复数据,显示第一条,第1张

去重没问题啊,distinct 就好了,显示第一条可以用row_number函数,不同版本hive的row_number有所不同,你自己查一下吧,row_number可以对同一个key从1开始编号的。

直接导入hive表

sqoop import --connect jdbc:postgresql://ip/db_name--username user_name --table table_name --hive-import -m 5

内部执行实际分三部,1.将数据导入hdfs(可在hdfs上找到相应目录),2.创建hive表名相同的表,3,将hdfs上数据传入hive表中

sqoop根据postgresql表创建hive表

sqoop create-hive-table --connect jdbc:postgresql://ip/db_name --username user_name --table table_name --hive-table hive_table_name( --hive-partition-key partition_name若需要分区则加入分区名称)

导入hive已经创建好的表中

sqoop import --connect jdbc:postgresql://ip/db_name --username user_name --table table_name --hive-import -m 5 --hive-table hive_table_name (--hive-partition-key partition_name --hive-partition-value partititon_value)

使用query导入hive表

sqoop import --connect jdbc:postgresql://ip/db_name --username user_name --query "select ,* from retail_tb_order where \$CONDITIONS" --hive-import -m 5 --hive-table hive_table_name (--hive-partition-key partition_name --hive-partition-value partititon_value)

注意:$CONDITIONS条件必须有,query子句若用双引号,则$CONDITIONS需要使用\转义,若使用单引号,则不需要转义。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/10699683.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-10
下一篇 2023-05-10

发表评论

登录后才能评论

评论列表(0条)

保存