Skip to content

Commit a13c55e

Browse files
authored
Merge pull request #204 from MarcosBernal/master
change _create_table (catalog.py) default behavior to do not remove table if exists
2 parents 2f91a50 + 8e2a6d5 commit a13c55e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

awswrangler/catalog.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def create_parquet_table(
120120
columns_comments: Dict[str, str], optional
121121
Columns names and the related comments (e.g. {'col0': 'Column 0.', 'col1': 'Column 1.', 'col2': 'Partition.'}).
122122
mode: str
123-
'overwrite' to recreate any possible axisting table or 'append' to keep any possible axisting table.
123+
'overwrite' to recreate any possible existing table or 'append' to keep any possible existing table.
124124
boto3_session : boto3.Session(), optional
125125
Boto3 Session. The default boto3 session will be used if boto3_session receive None.
126126
@@ -967,11 +967,11 @@ def _create_table(
967967
if name in columns_comments:
968968
par["Comment"] = columns_comments[name]
969969
session: boto3.Session = _utils.ensure_session(session=boto3_session)
970-
exist: bool = does_table_exist(database=database, table=table, boto3_session=session)
971-
if (mode == "overwrite") or (exist is False):
970+
971+
if mode == "overwrite":
972972
delete_table_if_exists(database=database, table=table, boto3_session=session)
973-
client_glue: boto3.client = _utils.client(service_name="glue", session=session)
974-
client_glue.create_table(DatabaseName=database, TableInput=table_input)
973+
client_glue: boto3.client = _utils.client(service_name="glue", session=session)
974+
client_glue.create_table(DatabaseName=database, TableInput=table_input)
975975

976976

977977
def _csv_table_definition(

awswrangler/s3.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,7 @@ def store_parquet_metadata(
17301730
parameters: Optional[Dict[str, str]] = None,
17311731
columns_comments: Optional[Dict[str, str]] = None,
17321732
compression: Optional[str] = None,
1733+
mode: str = "overwrite",
17331734
boto3_session: Optional[boto3.Session] = None,
17341735
) -> Tuple[Dict[str, str], Optional[Dict[str, str]], Optional[Dict[str, List[str]]]]:
17351736
"""Infer and store parquet metadata on AWS Glue Catalog.
@@ -1769,6 +1770,8 @@ def store_parquet_metadata(
17691770
Columns names and the related comments (e.g. {'col0': 'Column 0.', 'col1': 'Column 1.', 'col2': 'Partition.'}).
17701771
compression: str, optional
17711772
Compression style (``None``, ``snappy``, ``gzip``, etc).
1773+
mode: str
1774+
'overwrite' to recreate any possible existing table or 'append' to keep any possible existing table.
17721775
boto3_session : boto3.Session(), optional
17731776
Boto3 Session. The default boto3 session will be used if boto3_session receive None.
17741777
@@ -1813,6 +1816,7 @@ def store_parquet_metadata(
18131816
description=description,
18141817
parameters=parameters,
18151818
columns_comments=columns_comments,
1819+
mode=mode,
18161820
boto3_session=session,
18171821
)
18181822
partitions_values: Dict[str, List[str]] = _data_types.athena_partitions_from_pyarrow_partitions(

0 commit comments

Comments
 (0)