ROW_NUMBER( ) OVER in impala

user1189851 picture user1189851 · Oct 6, 2014 · Viewed 29k times · Source

I have a use case where I need to use ROW_NUMBER() over PARTITION: Something like:

SELECT
  Column1 , Column 2
  ROW_NUMBER() OVER (
    PARTITION BY ACCOUNT_NUM
    ORDER BY FREQ, MAN, MODEL) as LEVEL
FROM
  TEST_TABLE

I need a workaround for this in Impala. Unfortunately Impala does not support sub queries and also does not support ROW_NUMBER() OVER functionality. Thank you for your help.

Answer

Tagar picture Tagar · Nov 8, 2016

ROW_NUMBER() OVER PARTITION was added in CDH 5.2:

https://www.cloudera.com/documentation/enterprise/latest/topics/impala_analytic_functions.html#row_number

ROW_NUMBER() OVER([partition_by_clause] order_by_clause)