From 5087a463974e548d78cb169264bb78935428e4a6 Mon Sep 17 00:00:00 2001
From: Valentin Lorentz <vlorentz@softwareheritage.org>
Date: Thu, 10 Nov 2022 10:11:51 +0100
Subject: [PATCH] athena: Fix create_table to work with restricted permissions

For some reason, using a non-existing database works when working with
credentials with unnecessarily high privileges (though it is not clear
to me which permissions allow this).
---
 swh/dataset/athena.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/swh/dataset/athena.py b/swh/dataset/athena.py
index 779b231..1798c1d 100644
--- a/swh/dataset/athena.py
+++ b/swh/dataset/athena.py
@@ -107,12 +107,14 @@ def create_tables(database_name, dataset_location, output_location=None, replace
     """
     client = boto3.client("athena")
     client.output_location = output_location
-    client.database_name = database_name
+
+    client.database_name = "default"  # we have to pick some existing database
     query(
         client,
         create_database(database_name),
         desc="Creating {} database".format(database_name),
     )
+    client.database_name = database_name
 
     if replace:
         for table in TABLES:
-- 
GitLab