hive order by不在子查询中工作

时间:2014-06-19 22:46:25

标签: hive

我有这个查询 -

CREATE TABLE traces_orc1 
(pc BIGINT, 
 opcode STRING, 
 frequency STRING) 
ROW FORMAT DELIMITED FIELDS TERMINATED BY '44' 
STORED AS ORC;

INSERT OVERWRITE TABLE traces_orc1 
SELECT CONV(pc,16,10) as pc, 
opcode, COUNT(*) 
FROM traces_texttemp as frequency 
GROUP BY pc, opcode;


CREATE TABLE traces_orctemp 
(pc BIGINT, 
 opcode STRING, 
 frequency STRING) 
ROW FORMAT DELIMITED FIELDS TERMINATED BY '44' 
STORED AS ORC;

INSERT OVERWRITE TABLE traces_orctemp 
SELECT pc, opcode, frequency FROM traces_orc1 ORDER BY pc ASC;

我试图将这两个语句合并为一个 -

CREATE TABLE traces_orc2 (
pcount BIGINT, 
opcode STRING, 
frequency STRING) 
ROW FORMAT DELIMITED FIELDS TERMINATED BY '44' 
STORED AS TEXTFILE;

INSERT OVERWRITE TABLE traces_orc2 
SELECT CONV(TRIM(traces_text.pc),16,10) as pcount, 
opcode, COUNT(*) as frequency 
FROM traces_text
GROUP BY pcount,opcode
ORDER BY pcount ASC;

但这不会奏效。当我将其作为一个语句写出时,order by无法正常工作

任何输入??

1 个答案:

答案 0 :(得分:0)

你试过了吗?

INSERT OVERWRITE TABLE traces_orc2 
select pcount, opcode, frequency from 
(SELECT CONV(TRIM(traces_text.pc),16,10) as pcount, 
opcode, COUNT(*) as frequency 
FROM traces_text
GROUP BY pcount,opcode)
ORDER BY pcount ASC;

它可能会迫使Hive为分拣开第二个减少阶段。