Search code examples
sqlamazon-athenapresto

Unique row identifier in Presto SQL


I work on Presto SQL tables that don't have unique row identifiers. The only way to identify a specific record is to query all of its fields.

Is there in Presto some kind of hidden field, say ROW_PRIMARY_KEY, that would allow me to uniquely identify records in my tables?


Solution

  • Short of a primary key, you could just toss in a

    ROW_NUMBER() OVER (PARTITION BY some, columns ORDER BY some_other_column) as rn 
    

    This will define a row number where some, columns would be a psuedo-primary key.