@@ -44,6 +44,7 @@ def _create_table( # pylint: disable=too-many-branches,too-many-statements,too-
4444 projection_values : Optional [Dict [str , str ]],
4545 projection_intervals : Optional [Dict [str , str ]],
4646 projection_digits : Optional [Dict [str , str ]],
47+ projection_formats : Optional [Dict [str , str ]],
4748 projection_storage_location_template : Optional [str ],
4849 catalog_id : Optional [str ],
4950) -> None :
@@ -67,11 +68,13 @@ def _create_table( # pylint: disable=too-many-branches,too-many-statements,too-
6768 projection_values = projection_values if projection_values else {}
6869 projection_intervals = projection_intervals if projection_intervals else {}
6970 projection_digits = projection_digits if projection_digits else {}
71+ projection_formats = projection_formats if projection_formats else {}
7072 projection_types = {sanitize_column_name (k ): v for k , v in projection_types .items ()}
7173 projection_ranges = {sanitize_column_name (k ): v for k , v in projection_ranges .items ()}
7274 projection_values = {sanitize_column_name (k ): v for k , v in projection_values .items ()}
7375 projection_intervals = {sanitize_column_name (k ): v for k , v in projection_intervals .items ()}
7476 projection_digits = {sanitize_column_name (k ): v for k , v in projection_digits .items ()}
77+ projection_formats = {sanitize_column_name (k ): v for k , v in projection_formats .items ()}
7578 for k , v in projection_types .items ():
7679 dtype : Optional [str ] = partitions_types .get (k )
7780 if dtype is None and projection_storage_location_template is None :
@@ -98,6 +101,10 @@ def _create_table( # pylint: disable=too-many-branches,too-many-statements,too-
98101 mode = _update_if_necessary (
99102 dic = table_input ["Parameters" ], key = f"projection.{ k } .digits" , value = str (v ), mode = mode
100103 )
104+ for k , v in projection_formats .items ():
105+ mode = _update_if_necessary (
106+ dic = table_input ["Parameters" ], key = f"projection.{ k } .format" , value = str (v ), mode = mode
107+ )
101108 mode = _update_if_necessary (
102109 table_input ["Parameters" ],
103110 key = "storage.location.template" ,
@@ -266,6 +273,7 @@ def _create_parquet_table(
266273 projection_values : Optional [Dict [str , str ]],
267274 projection_intervals : Optional [Dict [str , str ]],
268275 projection_digits : Optional [Dict [str , str ]],
276+ projection_formats : Optional [Dict [str , str ]],
269277 projection_storage_location_template : Optional [str ],
270278 boto3_session : Optional [boto3 .Session ],
271279 catalog_table_input : Optional [Dict [str , Any ]],
@@ -318,6 +326,7 @@ def _create_parquet_table(
318326 projection_values = projection_values ,
319327 projection_intervals = projection_intervals ,
320328 projection_digits = projection_digits ,
329+ projection_formats = projection_formats ,
321330 projection_storage_location_template = projection_storage_location_template ,
322331 catalog_id = catalog_id ,
323332 )
@@ -350,6 +359,7 @@ def _create_csv_table( # pylint: disable=too-many-arguments,too-many-locals
350359 projection_values : Optional [Dict [str , str ]],
351360 projection_intervals : Optional [Dict [str , str ]],
352361 projection_digits : Optional [Dict [str , str ]],
362+ projection_formats : Optional [Dict [str , str ]],
353363 projection_storage_location_template : Optional [str ],
354364 catalog_table_input : Optional [Dict [str , Any ]],
355365 catalog_id : Optional [str ],
@@ -398,6 +408,7 @@ def _create_csv_table( # pylint: disable=too-many-arguments,too-many-locals
398408 projection_values = projection_values ,
399409 projection_intervals = projection_intervals ,
400410 projection_digits = projection_digits ,
411+ projection_formats = projection_formats ,
401412 projection_storage_location_template = projection_storage_location_template ,
402413 catalog_id = catalog_id ,
403414 )
@@ -428,6 +439,7 @@ def _create_json_table( # pylint: disable=too-many-arguments
428439 projection_values : Optional [Dict [str , str ]],
429440 projection_intervals : Optional [Dict [str , str ]],
430441 projection_digits : Optional [Dict [str , str ]],
442+ projection_formats : Optional [Dict [str , str ]],
431443 projection_storage_location_template : Optional [str ],
432444 catalog_table_input : Optional [Dict [str , Any ]],
433445 catalog_id : Optional [str ],
@@ -474,6 +486,7 @@ def _create_json_table( # pylint: disable=too-many-arguments
474486 projection_values = projection_values ,
475487 projection_intervals = projection_intervals ,
476488 projection_digits = projection_digits ,
489+ projection_formats = projection_formats ,
477490 projection_storage_location_template = projection_storage_location_template ,
478491 catalog_id = catalog_id ,
479492 )
@@ -676,6 +689,7 @@ def create_parquet_table(
676689 projection_values : Optional [Dict [str , str ]] = None ,
677690 projection_intervals : Optional [Dict [str , str ]] = None ,
678691 projection_digits : Optional [Dict [str , str ]] = None ,
692+ projection_formats : Optional [Dict [str , str ]] = None ,
679693 projection_storage_location_template : Optional [str ] = None ,
680694 boto3_session : Optional [boto3 .Session ] = None ,
681695) -> None :
@@ -741,6 +755,10 @@ def create_parquet_table(
741755 Dictionary of partitions names and Athena projections digits.
742756 https://docs.aws.amazon.com/athena/latest/ug/partition-projection-supported-types.html
743757 (e.g. {'col_name': '1', 'col2_name': '2'})
758+ projection_formats: Optional[Dict[str, str]]
759+ Dictionary of partitions names and Athena projections formats.
760+ https://docs.aws.amazon.com/athena/latest/ug/partition-projection-supported-types.html
761+ (e.g. {'col_date': 'yyyy-MM-dd', 'col2_timestamp': 'yyyy-MM-dd HH:mm:ss'})
744762 projection_storage_location_template: Optional[str]
745763 Value which is allows Athena to properly map partition values if the S3 file locations do not follow
746764 a typical `.../column=value/...` pattern.
@@ -796,14 +814,15 @@ def create_parquet_table(
796814 projection_values = projection_values ,
797815 projection_intervals = projection_intervals ,
798816 projection_digits = projection_digits ,
817+ projection_formats = projection_formats ,
799818 projection_storage_location_template = projection_storage_location_template ,
800819 boto3_session = boto3_session ,
801820 catalog_table_input = catalog_table_input ,
802821 )
803822
804823
805824@apply_configs
806- def create_csv_table ( # pylint: disable=too-many-arguments
825+ def create_csv_table ( # pylint: disable=too-many-arguments,too-many-locals
807826 database : str ,
808827 table : str ,
809828 path : str ,
@@ -830,6 +849,7 @@ def create_csv_table( # pylint: disable=too-many-arguments
830849 projection_values : Optional [Dict [str , str ]] = None ,
831850 projection_intervals : Optional [Dict [str , str ]] = None ,
832851 projection_digits : Optional [Dict [str , str ]] = None ,
852+ projection_formats : Optional [Dict [str , str ]] = None ,
833853 projection_storage_location_template : Optional [str ] = None ,
834854 catalog_id : Optional [str ] = None ,
835855) -> None :
@@ -908,6 +928,10 @@ def create_csv_table( # pylint: disable=too-many-arguments
908928 Dictionary of partitions names and Athena projections digits.
909929 https://docs.aws.amazon.com/athena/latest/ug/partition-projection-supported-types.html
910930 (e.g. {'col_name': '1', 'col2_name': '2'})
931+ projection_formats: Optional[Dict[str, str]]
932+ Dictionary of partitions names and Athena projections formats.
933+ https://docs.aws.amazon.com/athena/latest/ug/partition-projection-supported-types.html
934+ (e.g. {'col_date': 'yyyy-MM-dd', 'col2_timestamp': 'yyyy-MM-dd HH:mm:ss'})
911935 projection_storage_location_template: Optional[str]
912936 Value which is allows Athena to properly map partition values if the S3 file locations do not follow
913937 a typical `.../column=value/...` pattern.
@@ -967,6 +991,7 @@ def create_csv_table( # pylint: disable=too-many-arguments
967991 projection_values = projection_values ,
968992 projection_intervals = projection_intervals ,
969993 projection_digits = projection_digits ,
994+ projection_formats = projection_formats ,
970995 projection_storage_location_template = projection_storage_location_template ,
971996 boto3_session = boto3_session ,
972997 catalog_table_input = catalog_table_input ,
@@ -1003,6 +1028,7 @@ def create_json_table( # pylint: disable=too-many-arguments
10031028 projection_values : Optional [Dict [str , str ]] = None ,
10041029 projection_intervals : Optional [Dict [str , str ]] = None ,
10051030 projection_digits : Optional [Dict [str , str ]] = None ,
1031+ projection_formats : Optional [Dict [str , str ]] = None ,
10061032 projection_storage_location_template : Optional [str ] = None ,
10071033 catalog_id : Optional [str ] = None ,
10081034) -> None :
@@ -1077,6 +1103,10 @@ def create_json_table( # pylint: disable=too-many-arguments
10771103 Dictionary of partitions names and Athena projections digits.
10781104 https://docs.aws.amazon.com/athena/latest/ug/partition-projection-supported-types.html
10791105 (e.g. {'col_name': '1', 'col2_name': '2'})
1106+ projection_formats: Optional[Dict[str, str]]
1107+ Dictionary of partitions names and Athena projections formats.
1108+ https://docs.aws.amazon.com/athena/latest/ug/partition-projection-supported-types.html
1109+ (e.g. {'col_date': 'yyyy-MM-dd', 'col2_timestamp': 'yyyy-MM-dd HH:mm:ss'})
10801110 projection_storage_location_template: Optional[str]
10811111 Value which is allows Athena to properly map partition values if the S3 file locations do not follow
10821112 a typical `.../column=value/...` pattern.
@@ -1135,6 +1165,7 @@ def create_json_table( # pylint: disable=too-many-arguments
11351165 projection_values = projection_values ,
11361166 projection_intervals = projection_intervals ,
11371167 projection_digits = projection_digits ,
1168+ projection_formats = projection_formats ,
11381169 projection_storage_location_template = projection_storage_location_template ,
11391170 boto3_session = boto3_session ,
11401171 catalog_table_input = catalog_table_input ,
0 commit comments