22

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.

Alberto Solano
  • 7,972
  • 3
  • 38
  • 61
user3107144
  • 231
  • 1
  • 2
  • 3

3 Answers3

41

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
Nigel Tufnel
  • 11,146
  • 4
  • 35
  • 31
10

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.

kalpesh
  • 328
  • 3
  • 14
0

There is one trick:

Select distinct * from (select * from tableA)abc

Weird but yes it works!

borchvm
  • 3,533
  • 16
  • 44
  • 45
Mithun
  • 1