sws-spark-dissemination-helper 0.0.95__py3-none-any.whl → 0.0.96__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.
@@ -1,4 +1,5 @@
1
1
  import logging
2
+ import time
2
3
  from copy import copy
3
4
  from typing import Dict, List, Tuple
4
5
 
@@ -389,6 +390,15 @@ class SWSBronzeIcebergSparkHelper:
389
390
  self.spark.sql(
390
391
  f"ALTER TABLE {self.iceberg_tables.BRONZE.iceberg_id} CREATE TAG `{self.tag_name}`"
391
392
  )
393
+ while (
394
+ self.spark.sql(
395
+ f"SELECT * FROM {self.iceberg_tables.BRONZE.iceberg_id}.refs"
396
+ )
397
+ .filter((col("type") == lit("TAG")) & (col("name") == lit(self.tag_name)))
398
+ .count()
399
+ ) == 0:
400
+ logging.info(f"Waiting for the tag {self.tag_name} to be created")
401
+ time.sleep(2)
392
402
 
393
403
  logging.info(f"bronze tag '{self.tag_name}' created")
394
404
 
@@ -447,14 +457,31 @@ class SWSBronzeIcebergSparkHelper:
447
457
  def write_bronze_disseminated_tag_data_to_iceberg_and_csv(
448
458
  self, dimensions: Dict[str, List[str]]
449
459
  ) -> DataFrame:
450
-
451
- refs = self.spark.sql(f"SELECT * FROM {self.iceberg_tables.BRONZE.iceberg_id}.refs").collect()
460
+
461
+ refs = self.spark.sql(
462
+ f"SELECT * FROM {self.iceberg_tables.BRONZE.iceberg_id}.refs"
463
+ ).collect()
452
464
  logging.info(f"bronze refs: {refs}")
453
465
 
454
466
  create_branch_query = f"ALTER TABLE {self.iceberg_tables.BRONZE.iceberg_id}.`tag_{self.tag_name}` CREATE OR REPLACE BRANCH `diss_tag_{self.tag_name}`" # AS OF VERSION `{tag_name}`
455
467
  logging.info(f"create_branch_query: {create_branch_query}")
456
468
  create_branch_query_result = self.spark.sql(create_branch_query).collect()
457
469
 
470
+ while (
471
+ self.spark.sql(
472
+ f"SELECT * FROM {self.iceberg_tables.BRONZE.iceberg_id}.refs"
473
+ )
474
+ .filter(
475
+ (col("type") == lit("BRANCH"))
476
+ & (col("name") == lit(f"diss_tag_{self.tag_name}"))
477
+ )
478
+ .count()
479
+ ) == 0:
480
+ logging.info(
481
+ f"Waiting for the branch {self.tag_name} diss_tag_{self.tag_name} to be created"
482
+ )
483
+ time.sleep(2)
484
+
458
485
  logging.info(f"result of create_branch_query: {create_branch_query_result}")
459
486
 
460
487
  self.disseminated_tag_df = self.spark.read.option(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sws-spark-dissemination-helper
3
- Version: 0.0.95
3
+ Version: 0.0.96
4
4
  Summary: A Python helper package providing streamlined Spark functions for efficient data dissemination processes
5
5
  Project-URL: Repository, https://bitbucket.org/cioapps/sws-it-python-spark-dissemination-helper
6
6
  Author-email: Daniele Mansillo <danielemansillo@gmail.com>
@@ -1,11 +1,11 @@
1
- sws_spark_dissemination_helper/SWSBronzeIcebergSparkHelper.py,sha256=ja7zXIJNYdzvSiHdMB8oeKSQkLVu-FSUhy0vn_myhnU,21086
1
+ sws_spark_dissemination_helper/SWSBronzeIcebergSparkHelper.py,sha256=R9FsWyoX_iE2re5BUXer6QGDR45LJ_Z4P4lLET9Ij88,21964
2
2
  sws_spark_dissemination_helper/SWSGoldIcebergSparkHelper.py,sha256=ZC7hxkppo6qmfCc2z5vm2Y2iH1901F-rx9Er9cxuzP4,16037
3
3
  sws_spark_dissemination_helper/SWSPostgresSparkReader.py,sha256=ja7AbOfbmC_EXHCJk7UMDzzbA-LRxzPkaaUmuvcihJ8,17449
4
4
  sws_spark_dissemination_helper/SWSSilverIcebergSparkHelper.py,sha256=zEppNq5shiHZH2yt5faWGsb5QEmpAQS0ToIrG6fmv6o,22231
5
5
  sws_spark_dissemination_helper/__init__.py,sha256=Efjoe9V4vGXWVp-DY5P6NbRwIUr_zkZJkDmMi-lf5Bc,262
6
6
  sws_spark_dissemination_helper/constants.py,sha256=hpHHlbojShMWRfyIelXz6c5BqFzO48Oap1zmztlMMrs,11349
7
7
  sws_spark_dissemination_helper/utils.py,sha256=6SzrXX0xhvynRyv-vRFDbc6V4UNe_RzKKETZAtefnhg,21341
8
- sws_spark_dissemination_helper-0.0.95.dist-info/METADATA,sha256=5oamHa9qI0T6_rNyZc4NLUM4kPUaCGfmHOypaNyky8s,2823
9
- sws_spark_dissemination_helper-0.0.95.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- sws_spark_dissemination_helper-0.0.95.dist-info/licenses/LICENSE,sha256=zFzeb_j_6pXEHwH8Z0OpIkKFJk7vmhZjdem-K0d4zU4,1073
11
- sws_spark_dissemination_helper-0.0.95.dist-info/RECORD,,
8
+ sws_spark_dissemination_helper-0.0.96.dist-info/METADATA,sha256=ugZY_gSFF51c4V65tLQAe4ERI8Cu-WgBY2VxuWJB3Ow,2823
9
+ sws_spark_dissemination_helper-0.0.96.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ sws_spark_dissemination_helper-0.0.96.dist-info/licenses/LICENSE,sha256=zFzeb_j_6pXEHwH8Z0OpIkKFJk7vmhZjdem-K0d4zU4,1073
11
+ sws_spark_dissemination_helper-0.0.96.dist-info/RECORD,,