1

我在 Hive 中创建了一个表,如下所示:

CREATE TABLE application_path
    (userId STRING, sessId BIGINT, accesstime BIGINT, actionId STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '#'
STORED AS TEXTFILE;

在此表上运行查询:

SELECT DISTINCT userId FROM application_path;

给出预期的结果:

user1@domain.com
user2@domain.com
user3@domain.com
...

然后我更改了声明以添加一个分区:

CREATE TABLE application_path
    (sessId BIGINT, accesstime BIGINT, actionId STRING)
PARTITIONED BY(userId STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '#'
STORED AS TEXTFILE;

现在查询 SELECT DISTINCT userId... 像以前一样运行几秒钟,但最终返回任何内容。

我刚刚注意到语法:

SHOW PARTITIONS application_path;

但我想知道这是否是从分区列中获取唯一(不同)值的唯一方法。SHOW PARTITION 的输出甚至不能完全替代您从 SELECT DISTINCT 获得的内容,因为列名是每一行的前缀:

hive> show partitions application_path;            
OK
userid=user1@domain.com
userid=user2@domain.com
userid=user3@domain.com
...

对我来说奇怪的是 usedId 可以在 GROUP BY 中与其他列一起使用,例如:

SELECT userId, sessId FROM application_path GROUP BY userId, sessId;

但确实返回任何内容:

SELECT userId FROM application_path GROUP BY userId;
4

1 回答 1

2

I experienced the same issue, it will be fixed in 0.10 https://issues.apache.org/jira/browse/HIVE-2955

于 2012-11-01T10:08:30.643 回答