How to get input file name as column in AWS Athena external tables

Rajeev picture Rajeev · May 16, 2017 · Viewed 15k times · Source

I have external tables created in AWS Athena to query S3 data, however, the location path has 1000+ files. So I need the corresponding filename of the record to be displayed as a column in the table.

select file_name , col1 from table where file_name = "test20170516"

In short, I need to know INPUT__FILE__NAME(hive) equivalent in AWS Athena Presto or any other ways to achieve the same.

Answer

jens walter picture jens walter · May 16, 2017

You can do this with the $path pseudo column.

select "$path" from table