Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Message: TOK_ALLCOLREF is not supported in current context - while Using DISTINCT in HIVE

I'm using the simple command: SELECT DISTINCT * FROM first_working_table; in HIVE 0.11, and I'm receiving the following error message:

FAILED: SemanticException TOK_ALLCOLREF is not supported in current context.

Does anyone know why this is happening? How can we solve it?

Thank you, Gal.

like image 993
user3107144 Avatar asked Jan 13 '14 10:01

user3107144


2 Answers

Hive doesn't support DISTINCT * syntax. You can manually specify every field of the table to get the same result:

SELECT DISTINCT field1, field2, ...., fieldN
  FROM first_working_table
like image 54
Nigel Tufnel Avatar answered Nov 14 '22 10:11

Nigel Tufnel


As specified in earlier comment distinct * not supported. Which is true. One trick can be like this.

Distinct * can be used in this fashion:

select distinct * from (
select t1.col1,t1.col2,t1.col3,t2.* from t1,t2
)tbl;

I have used this syntax in Hive 2.x. So I can confirm that this works.

like image 38
kalpesh Avatar answered Nov 14 '22 10:11

kalpesh