2
2
import os
3
3
import posixpath as path
4
4
import tempfile
5
+ from enum import Enum
5
6
from itertools import chain
6
7
from textwrap import dedent
7
8
from threading import Lock
53
54
boto3_client_lock = Lock ()
54
55
55
56
57
+ class AthenaCatalogType (Enum ):
58
+ GLUE = "GLUE"
59
+ LAMBDA = "LAMBDA"
60
+ HIVE = "HIVE"
61
+
62
+
56
63
class AthenaAdapter (SQLAdapter ):
57
64
BATCH_CREATE_PARTITION_API_LIMIT = 100
58
65
BATCH_DELETE_PARTITION_API_LIMIT = 25
@@ -416,9 +423,8 @@ def _get_one_catalog(
416
423
manifest : Manifest ,
417
424
) -> agate .Table :
418
425
data_catalog = self ._get_data_catalog (information_schema .path .database )
419
- catalog_id = get_catalog_id (data_catalog )
420
426
421
- if data_catalog ["Type" ] == " GLUE" :
427
+ if data_catalog ["Type" ] == AthenaCatalogType . GLUE . value :
422
428
conn = self .connections .get_thread_connection ()
423
429
client = conn .handle
424
430
with boto3_client_lock :
@@ -433,6 +439,7 @@ def _get_one_catalog(
433
439
}
434
440
# If the catalog is `awsdatacatalog` we don't need to pass CatalogId as boto3
435
441
# infers it from the account Id.
442
+ catalog_id = get_catalog_id (data_catalog )
436
443
if catalog_id :
437
444
kwargs ["CatalogId" ] = catalog_id
438
445
@@ -441,13 +448,15 @@ def _get_one_catalog(
441
448
if relations and table ["Name" ] in relations :
442
449
catalog .extend (self ._get_one_table_for_catalog (table , information_schema .path .database ))
443
450
table = agate .Table .from_object (catalog )
444
- else :
451
+ elif data_catalog [ "Type" ] == AthenaCatalogType . LAMBDA . value :
445
452
kwargs = {"information_schema" : information_schema , "schemas" : schemas }
446
453
table = self .execute_macro (
447
454
GET_CATALOG_MACRO_NAME ,
448
455
kwargs = kwargs ,
449
456
manifest = manifest ,
450
457
)
458
+ else :
459
+ raise NotImplementedError (f"Type of catalog { data_catalog ['Type' ]} not supported: { data_catalog ['Name' ]} " )
451
460
452
461
filtered_table = self ._catalog_filter_table (table , manifest )
453
462
return self ._join_catalog_table_owners (filtered_table , manifest )
0 commit comments