@@ -44,6 +44,7 @@ def _create_table( # pylint: disable=too-many-branches,too-many-statements,too-
44
44
projection_values : Optional [Dict [str , str ]],
45
45
projection_intervals : Optional [Dict [str , str ]],
46
46
projection_digits : Optional [Dict [str , str ]],
47
+ projection_formats : Optional [Dict [str , str ]],
47
48
projection_storage_location_template : Optional [str ],
48
49
catalog_id : Optional [str ],
49
50
) -> None :
@@ -67,11 +68,13 @@ def _create_table( # pylint: disable=too-many-branches,too-many-statements,too-
67
68
projection_values = projection_values if projection_values else {}
68
69
projection_intervals = projection_intervals if projection_intervals else {}
69
70
projection_digits = projection_digits if projection_digits else {}
71
+ projection_formats = projection_formats if projection_formats else {}
70
72
projection_types = {sanitize_column_name (k ): v for k , v in projection_types .items ()}
71
73
projection_ranges = {sanitize_column_name (k ): v for k , v in projection_ranges .items ()}
72
74
projection_values = {sanitize_column_name (k ): v for k , v in projection_values .items ()}
73
75
projection_intervals = {sanitize_column_name (k ): v for k , v in projection_intervals .items ()}
74
76
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 ()}
75
78
for k , v in projection_types .items ():
76
79
dtype : Optional [str ] = partitions_types .get (k )
77
80
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-
98
101
mode = _update_if_necessary (
99
102
dic = table_input ["Parameters" ], key = f"projection.{ k } .digits" , value = str (v ), mode = mode
100
103
)
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
+ )
101
108
mode = _update_if_necessary (
102
109
table_input ["Parameters" ],
103
110
key = "storage.location.template" ,
@@ -266,6 +273,7 @@ def _create_parquet_table(
266
273
projection_values : Optional [Dict [str , str ]],
267
274
projection_intervals : Optional [Dict [str , str ]],
268
275
projection_digits : Optional [Dict [str , str ]],
276
+ projection_formats : Optional [Dict [str , str ]],
269
277
projection_storage_location_template : Optional [str ],
270
278
boto3_session : Optional [boto3 .Session ],
271
279
catalog_table_input : Optional [Dict [str , Any ]],
@@ -318,6 +326,7 @@ def _create_parquet_table(
318
326
projection_values = projection_values ,
319
327
projection_intervals = projection_intervals ,
320
328
projection_digits = projection_digits ,
329
+ projection_formats = projection_formats ,
321
330
projection_storage_location_template = projection_storage_location_template ,
322
331
catalog_id = catalog_id ,
323
332
)
@@ -350,6 +359,7 @@ def _create_csv_table( # pylint: disable=too-many-arguments,too-many-locals
350
359
projection_values : Optional [Dict [str , str ]],
351
360
projection_intervals : Optional [Dict [str , str ]],
352
361
projection_digits : Optional [Dict [str , str ]],
362
+ projection_formats : Optional [Dict [str , str ]],
353
363
projection_storage_location_template : Optional [str ],
354
364
catalog_table_input : Optional [Dict [str , Any ]],
355
365
catalog_id : Optional [str ],
@@ -398,6 +408,7 @@ def _create_csv_table( # pylint: disable=too-many-arguments,too-many-locals
398
408
projection_values = projection_values ,
399
409
projection_intervals = projection_intervals ,
400
410
projection_digits = projection_digits ,
411
+ projection_formats = projection_formats ,
401
412
projection_storage_location_template = projection_storage_location_template ,
402
413
catalog_id = catalog_id ,
403
414
)
@@ -428,6 +439,7 @@ def _create_json_table( # pylint: disable=too-many-arguments
428
439
projection_values : Optional [Dict [str , str ]],
429
440
projection_intervals : Optional [Dict [str , str ]],
430
441
projection_digits : Optional [Dict [str , str ]],
442
+ projection_formats : Optional [Dict [str , str ]],
431
443
projection_storage_location_template : Optional [str ],
432
444
catalog_table_input : Optional [Dict [str , Any ]],
433
445
catalog_id : Optional [str ],
@@ -474,6 +486,7 @@ def _create_json_table( # pylint: disable=too-many-arguments
474
486
projection_values = projection_values ,
475
487
projection_intervals = projection_intervals ,
476
488
projection_digits = projection_digits ,
489
+ projection_formats = projection_formats ,
477
490
projection_storage_location_template = projection_storage_location_template ,
478
491
catalog_id = catalog_id ,
479
492
)
@@ -676,6 +689,7 @@ def create_parquet_table(
676
689
projection_values : Optional [Dict [str , str ]] = None ,
677
690
projection_intervals : Optional [Dict [str , str ]] = None ,
678
691
projection_digits : Optional [Dict [str , str ]] = None ,
692
+ projection_formats : Optional [Dict [str , str ]] = None ,
679
693
projection_storage_location_template : Optional [str ] = None ,
680
694
boto3_session : Optional [boto3 .Session ] = None ,
681
695
) -> None :
@@ -741,6 +755,10 @@ def create_parquet_table(
741
755
Dictionary of partitions names and Athena projections digits.
742
756
https://docs.aws.amazon.com/athena/latest/ug/partition-projection-supported-types.html
743
757
(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'})
744
762
projection_storage_location_template: Optional[str]
745
763
Value which is allows Athena to properly map partition values if the S3 file locations do not follow
746
764
a typical `.../column=value/...` pattern.
@@ -796,14 +814,15 @@ def create_parquet_table(
796
814
projection_values = projection_values ,
797
815
projection_intervals = projection_intervals ,
798
816
projection_digits = projection_digits ,
817
+ projection_formats = projection_formats ,
799
818
projection_storage_location_template = projection_storage_location_template ,
800
819
boto3_session = boto3_session ,
801
820
catalog_table_input = catalog_table_input ,
802
821
)
803
822
804
823
805
824
@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
807
826
database : str ,
808
827
table : str ,
809
828
path : str ,
@@ -830,6 +849,7 @@ def create_csv_table( # pylint: disable=too-many-arguments
830
849
projection_values : Optional [Dict [str , str ]] = None ,
831
850
projection_intervals : Optional [Dict [str , str ]] = None ,
832
851
projection_digits : Optional [Dict [str , str ]] = None ,
852
+ projection_formats : Optional [Dict [str , str ]] = None ,
833
853
projection_storage_location_template : Optional [str ] = None ,
834
854
catalog_id : Optional [str ] = None ,
835
855
) -> None :
@@ -908,6 +928,10 @@ def create_csv_table( # pylint: disable=too-many-arguments
908
928
Dictionary of partitions names and Athena projections digits.
909
929
https://docs.aws.amazon.com/athena/latest/ug/partition-projection-supported-types.html
910
930
(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'})
911
935
projection_storage_location_template: Optional[str]
912
936
Value which is allows Athena to properly map partition values if the S3 file locations do not follow
913
937
a typical `.../column=value/...` pattern.
@@ -967,6 +991,7 @@ def create_csv_table( # pylint: disable=too-many-arguments
967
991
projection_values = projection_values ,
968
992
projection_intervals = projection_intervals ,
969
993
projection_digits = projection_digits ,
994
+ projection_formats = projection_formats ,
970
995
projection_storage_location_template = projection_storage_location_template ,
971
996
boto3_session = boto3_session ,
972
997
catalog_table_input = catalog_table_input ,
@@ -1003,6 +1028,7 @@ def create_json_table( # pylint: disable=too-many-arguments
1003
1028
projection_values : Optional [Dict [str , str ]] = None ,
1004
1029
projection_intervals : Optional [Dict [str , str ]] = None ,
1005
1030
projection_digits : Optional [Dict [str , str ]] = None ,
1031
+ projection_formats : Optional [Dict [str , str ]] = None ,
1006
1032
projection_storage_location_template : Optional [str ] = None ,
1007
1033
catalog_id : Optional [str ] = None ,
1008
1034
) -> None :
@@ -1077,6 +1103,10 @@ def create_json_table( # pylint: disable=too-many-arguments
1077
1103
Dictionary of partitions names and Athena projections digits.
1078
1104
https://docs.aws.amazon.com/athena/latest/ug/partition-projection-supported-types.html
1079
1105
(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'})
1080
1110
projection_storage_location_template: Optional[str]
1081
1111
Value which is allows Athena to properly map partition values if the S3 file locations do not follow
1082
1112
a typical `.../column=value/...` pattern.
@@ -1135,6 +1165,7 @@ def create_json_table( # pylint: disable=too-many-arguments
1135
1165
projection_values = projection_values ,
1136
1166
projection_intervals = projection_intervals ,
1137
1167
projection_digits = projection_digits ,
1168
+ projection_formats = projection_formats ,
1138
1169
projection_storage_location_template = projection_storage_location_template ,
1139
1170
boto3_session = boto3_session ,
1140
1171
catalog_table_input = catalog_table_input ,
0 commit comments