sws-spark-dissemination-helper 0.0.191__py3-none-any.whl → 0.0.193__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sws_spark_dissemination_helper/SWSGoldIcebergSparkHelper.py +42 -7
- {sws_spark_dissemination_helper-0.0.191.dist-info → sws_spark_dissemination_helper-0.0.193.dist-info}/METADATA +1 -1
- {sws_spark_dissemination_helper-0.0.191.dist-info → sws_spark_dissemination_helper-0.0.193.dist-info}/RECORD +5 -5
- {sws_spark_dissemination_helper-0.0.191.dist-info → sws_spark_dissemination_helper-0.0.193.dist-info}/WHEEL +0 -0
- {sws_spark_dissemination_helper-0.0.191.dist-info → sws_spark_dissemination_helper-0.0.193.dist-info}/licenses/LICENSE +0 -0
|
@@ -71,6 +71,9 @@ class SWSGoldIcebergSparkHelper:
|
|
|
71
71
|
self.display_decimals_df = self.sws_postgres_spark_reader.read_pg_table(
|
|
72
72
|
pg_table=DatasetDatatables.DISPLAY_DECIMALS.id,
|
|
73
73
|
custom_schema=DatasetDatatables.DISPLAY_DECIMALS.schema,
|
|
74
|
+
).filter(
|
|
75
|
+
(col("domain") == lit(self.domain_code))
|
|
76
|
+
| ((col("domain") == lit("DEFAULT")))
|
|
74
77
|
)
|
|
75
78
|
|
|
76
79
|
def _get_dim_time_flag_columns(self) -> Tuple[List[str], List[str], str, List[str]]:
|
|
@@ -166,11 +169,15 @@ class SWSGoldIcebergSparkHelper:
|
|
|
166
169
|
display_decimals = int(rule["display_decimals"])
|
|
167
170
|
|
|
168
171
|
# Count actual decimal places in the current value
|
|
169
|
-
#
|
|
172
|
+
# Handle both regular decimals and scientific notation
|
|
173
|
+
# Convert scientific notation to decimal format first
|
|
174
|
+
value_str_normalized = F.when(
|
|
175
|
+
F.col(value_column).cast("string").rlike("[eE]"),
|
|
176
|
+
F.format_number(F.col(value_column).cast("double"), 20),
|
|
177
|
+
).otherwise(F.col(value_column).cast("string"))
|
|
178
|
+
|
|
170
179
|
actual_decimals = F.length(
|
|
171
|
-
F.regexp_extract(
|
|
172
|
-
F.col(value_column).cast("string"), DECIMAL_PLACES_REGEX, 1
|
|
173
|
-
)
|
|
180
|
+
F.regexp_extract(value_str_normalized, DECIMAL_PLACES_REGEX, 1)
|
|
174
181
|
)
|
|
175
182
|
|
|
176
183
|
# Add decimals condition
|
|
@@ -234,10 +241,14 @@ class SWSGoldIcebergSparkHelper:
|
|
|
234
241
|
)
|
|
235
242
|
|
|
236
243
|
# Only round if actual decimals >= target decimals, otherwise keep original
|
|
244
|
+
# Handle both regular decimals and scientific notation for default case
|
|
245
|
+
value_str_normalized_default = F.when(
|
|
246
|
+
F.col(value_column).cast("string").rlike("[eE]"),
|
|
247
|
+
F.format_number(F.col(value_column).cast("double"), 20),
|
|
248
|
+
).otherwise(F.col(value_column).cast("string"))
|
|
249
|
+
|
|
237
250
|
actual_decimals_default = F.length(
|
|
238
|
-
F.regexp_extract(
|
|
239
|
-
F.col(value_column).cast("string"), DECIMAL_PLACES_REGEX, 1
|
|
240
|
-
)
|
|
251
|
+
F.regexp_extract(value_str_normalized_default, DECIMAL_PLACES_REGEX, 1)
|
|
241
252
|
)
|
|
242
253
|
default_rounded = F.when(
|
|
243
254
|
actual_decimals_default >= lit(default_decimals), default_rounded
|
|
@@ -866,3 +877,27 @@ frozenset({"1", "2", "6", "7", "5", "8", "0", "4", "3", "9"})
|
|
|
866
877
|
frozenset({"1", "2", "6", "7", "5", "8", "0", "4", "3", "9"})
|
|
867
878
|
1
|
|
868
879
|
1
|
|
880
|
+
1
|
|
881
|
+
frozenset({"2", "4", "5", "7", "9", "3", "1", "0", "6", "8"})
|
|
882
|
+
1
|
|
883
|
+
1
|
|
884
|
+
2
|
|
885
|
+
frozenset({"2", "4", "5", "7", "9", "3", "1", "0", "6", "8"})
|
|
886
|
+
2
|
|
887
|
+
1
|
|
888
|
+
1
|
|
889
|
+
frozenset({"2", "4", "5", "7", "9", "3", "1", "0", "6", "8"})
|
|
890
|
+
1
|
|
891
|
+
1
|
|
892
|
+
2
|
|
893
|
+
frozenset({"2", "4", "5", "7", "9", "3", "1", "0", "6", "8"})
|
|
894
|
+
2
|
|
895
|
+
1
|
|
896
|
+
1
|
|
897
|
+
frozenset({"2", "4", "5", "7", "9", "3", "1", "0", "6", "8"})
|
|
898
|
+
1
|
|
899
|
+
1
|
|
900
|
+
1
|
|
901
|
+
frozenset({'2', '4', '5', '7', '9', '3', '1', '0', '6', '8'})
|
|
902
|
+
1
|
|
903
|
+
1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sws-spark-dissemination-helper
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.193
|
|
4
4
|
Summary: A Python helper package providing streamlined Spark functions for efficient data dissemination processes
|
|
5
5
|
Project-URL: Repository, https://github.com/un-fao/fao-sws-it-python-spark-dissemination-helper
|
|
6
6
|
Author-email: Daniele Mansillo <danielemansillo@gmail.com>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
sws_spark_dissemination_helper/SWSBronzeIcebergSparkHelper.py,sha256=N0eQ2LXtpPeZQCWYi85sMLmpXRzLA2erECiba8tqOAY,29595
|
|
2
2
|
sws_spark_dissemination_helper/SWSDatatablesExportHelper.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
sws_spark_dissemination_helper/SWSEasyIcebergSparkHelper.py,sha256=csqKyYglBkJSBvEkEa1_keHarZZAIJHaV0d64gGJy98,26379
|
|
4
|
-
sws_spark_dissemination_helper/SWSGoldIcebergSparkHelper.py,sha256=
|
|
4
|
+
sws_spark_dissemination_helper/SWSGoldIcebergSparkHelper.py,sha256=0LonVBX39-cEzo7tul06YX6G70BVo7zDE_uA2Lu-4Cc,33441
|
|
5
5
|
sws_spark_dissemination_helper/SWSPostgresSparkReader.py,sha256=5do-Cz2_GAEwNxPWRnnITjADMX8Wgi3aj_ynpQCUNmI,18467
|
|
6
6
|
sws_spark_dissemination_helper/SWSSilverIcebergSparkHelper.py,sha256=PGZPq_oNKRGOseYGuNujbcS8y-WuLmoDMN95faq0Css,26359
|
|
7
7
|
sws_spark_dissemination_helper/__init__.py,sha256=42TPbk7KxAud_qY3Sr_F4F7VjyofUlxEJkUXAFQsjRo,327
|
|
8
8
|
sws_spark_dissemination_helper/constants.py,sha256=MzuC7pqsXF89r-FK7hhmWaZSk5x3GB_YPVSfuK3NYVY,14056
|
|
9
9
|
sws_spark_dissemination_helper/utils.py,sha256=Ge8zXsUIcvFihALDNLF5kCu_tAdRQUE04xE6Yn9xQF4,22008
|
|
10
|
-
sws_spark_dissemination_helper-0.0.
|
|
11
|
-
sws_spark_dissemination_helper-0.0.
|
|
12
|
-
sws_spark_dissemination_helper-0.0.
|
|
13
|
-
sws_spark_dissemination_helper-0.0.
|
|
10
|
+
sws_spark_dissemination_helper-0.0.193.dist-info/METADATA,sha256=ZRxTBrv7G6LjvMrRpDNDEdAxCPIW0hjCmLIvZrE-hY0,2822
|
|
11
|
+
sws_spark_dissemination_helper-0.0.193.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
12
|
+
sws_spark_dissemination_helper-0.0.193.dist-info/licenses/LICENSE,sha256=zFzeb_j_6pXEHwH8Z0OpIkKFJk7vmhZjdem-K0d4zU4,1073
|
|
13
|
+
sws_spark_dissemination_helper-0.0.193.dist-info/RECORD,,
|
|
File without changes
|