sws-spark-dissemination-helper 0.0.177__tar.gz → 0.0.179__tar.gz

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.
Files changed (16) hide show
  1. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/PKG-INFO +1 -1
  2. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/pyproject.toml +1 -1
  3. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/src/sws_spark_dissemination_helper/SWSGoldIcebergSparkHelper.py +14 -8
  4. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/.gitignore +0 -0
  5. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/LICENSE +0 -0
  6. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/README.md +0 -0
  7. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/src/sws_spark_dissemination_helper/SWSBronzeIcebergSparkHelper.py +0 -0
  8. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/src/sws_spark_dissemination_helper/SWSDatatablesExportHelper.py +0 -0
  9. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/src/sws_spark_dissemination_helper/SWSEasyIcebergSparkHelper.py +0 -0
  10. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/src/sws_spark_dissemination_helper/SWSPostgresSparkReader.py +0 -0
  11. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/src/sws_spark_dissemination_helper/SWSSilverIcebergSparkHelper.py +0 -0
  12. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/src/sws_spark_dissemination_helper/__init__.py +0 -0
  13. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/src/sws_spark_dissemination_helper/constants.py +0 -0
  14. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/src/sws_spark_dissemination_helper/utils.py +0 -0
  15. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/tests/__init__.py +0 -0
  16. {sws_spark_dissemination_helper-0.0.177 → sws_spark_dissemination_helper-0.0.179}/tests/test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sws-spark-dissemination-helper
3
- Version: 0.0.177
3
+ Version: 0.0.179
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>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "sws-spark-dissemination-helper"
7
- version = "0.0.177"
7
+ version = "0.0.179"
8
8
  dependencies = [
9
9
  "annotated-types==0.7.0",
10
10
  "boto3>=1.40.0",
@@ -96,19 +96,19 @@ class SWSGoldIcebergSparkHelper:
96
96
  cols_to_keep_sws = cols_to_keep_sws + ["unit_of_measure_symbol"]
97
97
  return df.select(*cols_to_keep_sws)
98
98
 
99
- def add_display_decimals(self, df: DataFrame):
99
+ def round_to_display_decimals(self, df: DataFrame):
100
100
  col1_name, col2_name = (
101
101
  self.display_decimals.select("column_1_name", "column_2_name")
102
102
  .distinct()
103
103
  .collect()[0]
104
104
  )
105
- if col1_name.lower() not in [column.lower() for column in df.columns()]:
105
+ if col1_name.lower() not in [column.lower() for column in df.columns]:
106
106
  raise ValueError(
107
- f"{col1_name} is not part of the columns available for this dataset ({df.columns()})"
107
+ f"{col1_name} is not part of the columns available for this dataset ({df.columns})"
108
108
  )
109
- if col2_name.lower() not in [column.lower() for column in df.columns()]:
109
+ if col2_name.lower() not in [column.lower() for column in df.columns]:
110
110
  raise ValueError(
111
- f"{col2_name} is not part of the columns available for this dataset ({df.columns()})"
111
+ f"{col2_name} is not part of the columns available for this dataset ({df.columns})"
112
112
  )
113
113
 
114
114
  df = (
@@ -130,14 +130,20 @@ class SWSGoldIcebergSparkHelper:
130
130
  )
131
131
 
132
132
  df = df.withColumn(
133
- "display_decimals", F.coalesce(col("display_decimals"), lit("0"))
133
+ "display_decimals",
134
+ F.coalesce(col("display_decimals"), lit("0")).cast("INT"),
134
135
  ).withColumn(
135
136
  "value",
136
137
  F.round(
137
- col("value").cast("FLOAT"), col("display_decimals").cast("FLOAT")
138
- ).cast("STRING"),
138
+ F.col("value").cast("FLOAT") * F.pow(10, F.col("display_decimals")), 0
139
+ )
140
+ / F.pow(10, F.col("dec")).cast("STRING"),
139
141
  )
140
142
 
143
+ # F.round(
144
+ # col("value").cast("FLOAT"), col("display_decimals").cast("INT")
145
+ # ).cast("STRING"),
146
+
141
147
  return df
142
148
 
143
149
  def read_bronze_data(self) -> DataFrame: