Search code examples
amazon-web-servicesamazon-s3aws-glueamazon-athenaaws-glue-data-catalog

how to create multiple table from multiple folder with one location path and athena should also work on it with glue crawler


I have tried this not achieving required results- I have multiple CSV files in a folder of s3 bucket but when it creates multiple table for it then Athena returns zero results so I made a different folder for each file then it works fine. problem- but if in future more folders will be added then I have to go to crawler and have to add a new location path for each newly added folder so is there any way to do it automatically or some other way to do it. I am using glue crawler and s3 bucket athena for query run on multiple CSV files.


Solution

  • In general a table needs all of its files to be in a directory, and no other files to be in that directory.

    There is however, a mechanism that makes it possible to create tables that include just specific files. You can read more about that in the the second part of this answer: Partition Athena query by S3 created date (scroll down a bit after the horizontal rule). You can also find an example in the S3 Inventory documentation: https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html