假设我有下面的Hive表:
+---+-----------+------------+
| id|featureName|featureValue|
+---+-----------+------------+
|id1| a| 3|
|id1| b| 4|
|id2| a| 2|
|id2| c| 5|
|id3| d| 9|
+---+-----------+------------+
现在我运行一个类似下面示例的查询
SELECT
id,
collect_list(idx),
collect_list(val)
FROM
...
GROUP BY id
我是否保证“idx”和“val”将被聚合并保持它们的相对顺序?即
GOOD GOOD BAD
+---+------+------+ +---+------+------+ +---+------+------+
| id| idx| val| | id| idx| val| | id| idx| val|
+---+------+------+ +---+------+------+ +---+------+------+
|id3| [d]| [9]| |id3| [d]| [9]| |id3| [d]| [9]|
|id1|[a, b]|[3, 4]| |id1|[b, a]|[4, 3]| |id1|[a, b]|[4, 3]|
|id2|[a, c]|[2, 5]| |id2|[c, a]|[5, 2]| |id2|[a, c]|[5, 2]|
+---+------+------+ +---+------+------+ +---+------+------+
注:例如,这是不好的,因为对于id1[a,b]应该与[3,4]相关联(而不是[4,3])。id2相同
暂无答案!
目前还没有任何答案,快来回答吧!