Search code examples
amazon-web-servicesamazon-athenaaws-lake-formation

Athena Query fails after adding S3 bucket to Lake Formation


  • This is the error we get in Athena: HIVE_UNKNOWN_ERROR: Error creating an instance of com.facebook.presto.hive.lakeformation.CachingLakeFormationCredentialsProvider
  • The bucket is registered with Lake Formation
  • Role used for querying Athena has been given full access in Lake Formation to the database and all the tables in the database
  • Role has been given access to the underlying s3 bucket in the Data Locations section of Lake Formation.

Solution

  • Contacted AWS support. Turns out the problem was that I had "-" and "." in my Athena database name. According to Athena documentation:

    "The only acceptable characters for database names, table names, and column names are lowercase letters, numbers, and the underscore character." (https://docs.aws.amazon.com/athena/latest/ug/glue-best-practices.html#schema-names)

    For some reason this was not a problem when we were working outside the Lake Formation, but as soon as we registered the S3 location in LF, it started failing. I have confirmed that removing those characters from the database name solves the problem.