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

amazon s3amazon-athenaamazon-web-servicesprestosql

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.

Best Answer

You can do this with the $path pseudo column.

select "$path" from table
Related Topic