gpt4 book ai didi

csv - 从CSV文件创建Hive表时的唯一ID

转载 作者:行者123 更新时间:2023-12-02 21:38:17 27 4
gpt4 key购买 nike

我有一个要导出为Hive表的CSV文件列表,但是我很确定某些记录在CSV中是多余的。 CSV中的每个记录/行都由一个键标识,我想使用该键作为主键来生成表。我将如何生成Hive表,以确保没有重复的行?

最佳答案

ROW_NUMBER() OVER([partition_by_clause] order_by_clause)

返回以1开头的升序整数序列。
select x, row_number() over(order by x, property) as row_number, property from int_t;
+----+------------+----------+
| x | row_number | property |
+----+------------+----------+
| 1 | 1 | odd |
| 1 | 2 | square |
| 2 | 3 | even |
| 2 | 4 | prime |
| 3 | 5 | odd |
| 3 | 6 | prime |
| 4 | 7 | even |
| 4 | 8 | square |
| 5 | 9 | odd |
| 5 | 10 | prime |
| 6 | 11 | even |
| 6 | 12 | perfect |
| 7 | 13 | lucky |
| 7 | 14 | lucky |
| 7 | 15 | lucky |
| 7 | 16 | odd |
| 7 | 17 | prime |
| 8 | 18 | even |
| 9 | 19 | odd |
| 9 | 20 | square |
| 10 | 21 | even |
| 10 | 22 | round |
+----+------------+----------+

关于csv - 从CSV文件创建Hive表时的唯一ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30589287/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com