@@ -93,6 +93,7 @@ def create_parquet_table(
9393 parameters : Optional [Dict [str , str ]] = None ,
9494 columns_comments : Optional [Dict [str , str ]] = None ,
9595 mode : str = "overwrite" ,
96+ catalog_versioning : bool = False ,
9697 boto3_session : Optional [boto3 .Session ] = None ,
9798) -> None :
9899 """Create a Parquet Table (Metadata Only) in the AWS Glue Catalog.
@@ -121,6 +122,8 @@ def create_parquet_table(
121122 Columns names and the related comments (e.g. {'col0': 'Column 0.', 'col1': 'Column 1.', 'col2': 'Partition.'}).
122123 mode: str
123124 'overwrite' to recreate any possible existing table or 'append' to keep any possible existing table.
125+ catalog_versioning : bool
126+ If True and `mode="overwrite"`, creates an archived version of the table catalog before updating it.
124127 boto3_session : boto3.Session(), optional
125128 Boto3 Session. The default boto3 session will be used if boto3_session receive None.
126129
@@ -157,6 +160,7 @@ def create_parquet_table(
157160 parameters = parameters ,
158161 columns_comments = columns_comments ,
159162 mode = mode ,
163+ catalog_versioning = catalog_versioning ,
160164 boto3_session = boto3_session ,
161165 table_input = table_input ,
162166 )
@@ -865,6 +869,7 @@ def create_csv_table(
865869 parameters : Optional [Dict [str , str ]] = None ,
866870 columns_comments : Optional [Dict [str , str ]] = None ,
867871 mode : str = "overwrite" ,
872+ catalog_versioning : bool = False ,
868873 sep : str = "," ,
869874 boto3_session : Optional [boto3 .Session ] = None ,
870875) -> None :
@@ -884,16 +889,18 @@ def create_csv_table(
884889 Dictionary with keys as column names and vales as data types (e.g. {'col0': 'bigint', 'col1': 'double'}).
885890 partitions_types: Dict[str, str], optional
886891 Dictionary with keys as partition names and values as data types (e.g. {'col2': 'date'}).
887- compression: str, optional
892+ compression : str, optional
888893 Compression style (``None``, ``gzip``, etc).
889- description: str, optional
894+ description : str, optional
890895 Table description
891- parameters: Dict[str, str], optional
896+ parameters : Dict[str, str], optional
892897 Key/value pairs to tag the table.
893898 columns_comments: Dict[str, str], optional
894899 Columns names and the related comments (e.g. {'col0': 'Column 0.', 'col1': 'Column 1.', 'col2': 'Partition.'}).
895- mode: str
900+ mode : str
896901 'overwrite' to recreate any possible axisting table or 'append' to keep any possible axisting table.
902+ catalog_versioning : bool
903+ If True and `mode="overwrite"`, creates an archived version of the table catalog before updating it.
897904 sep : str
898905 String of length 1. Field delimiter for the output file.
899906 boto3_session : boto3.Session(), optional
@@ -937,6 +944,7 @@ def create_csv_table(
937944 parameters = parameters ,
938945 columns_comments = columns_comments ,
939946 mode = mode ,
947+ catalog_versioning = catalog_versioning ,
940948 boto3_session = boto3_session ,
941949 table_input = table_input ,
942950 )
@@ -949,6 +957,7 @@ def _create_table(
949957 parameters : Optional [Dict [str , str ]],
950958 columns_comments : Optional [Dict [str , str ]],
951959 mode : str ,
960+ catalog_versioning : bool ,
952961 boto3_session : Optional [boto3 .Session ],
953962 table_input : Dict [str , Any ],
954963):
@@ -967,10 +976,14 @@ def _create_table(
967976 if name in columns_comments :
968977 par ["Comment" ] = columns_comments [name ]
969978 session : boto3 .Session = _utils .ensure_session (session = boto3_session )
979+ client_glue : boto3 .client = _utils .client (service_name = "glue" , session = session )
970980 exist : bool = does_table_exist (database = database , table = table , boto3_session = session )
971- if (mode == "overwrite" ) or (exist is False ):
972- delete_table_if_exists (database = database , table = table , boto3_session = session )
973- client_glue : boto3 .client = _utils .client (service_name = "glue" , session = session )
981+ if mode not in ("overwrite" , "append" ): # pragma: no cover
982+ raise exceptions .InvalidArgument (f"{ mode } is not a valid mode. It must be 'overwrite' or 'append'." )
983+ if (exist is True ) and (mode == "overwrite" ):
984+ skip_archive : bool = not catalog_versioning
985+ client_glue .update_table (DatabaseName = database , TableInput = table_input , SkipArchive = skip_archive )
986+ elif exist is False :
974987 client_glue .create_table (DatabaseName = database , TableInput = table_input )
975988
976989
0 commit comments