omnata-plugin-runtime 0.10.25__py3-none-any.whl → 0.10.26__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.
@@ -3,7 +3,7 @@ Models used to represent JSON schemas and Snowflake view definitions.
3
3
  This was originally internal to the Sync Engine, but was moved to the
4
4
  plugin runtime so that it could be used for testing column expressions (formulas, etc).
5
5
  """
6
- from typing import Any, Dict, Optional, Literal, List, Union
6
+ from typing import Any, Dict, Optional, Literal, List, Union, Tuple
7
7
  from typing_extensions import Self
8
8
  from pydantic import BaseModel, Field, model_validator, computed_field
9
9
  from jinja2 import Environment
@@ -475,6 +475,15 @@ class SnowflakeViewParts(BaseModel):
475
475
  # first, we need to collapse all referenced columns into a single map
476
476
  all_referenced_columns:Dict[str,List[str]] = {}
477
477
  for part in [self.main_part] + self.joined_parts:
478
+ # if the main part references any columns in this part in its joins, we need to include those columns
479
+ aliases_for_stream = [j.join_stream_alias for j in self.main_part.joins
480
+ if j.join_stream_name == part.stream_name]
481
+ columns_used_in_joins = [
482
+ j.left_column for j in self.main_part.joins if j.left_alias in aliases_for_stream
483
+ ]
484
+ if part.stream_name not in all_referenced_columns:
485
+ all_referenced_columns[part.stream_name] = []
486
+ all_referenced_columns[part.stream_name] += columns_used_in_joins
478
487
  for column in part.columns:
479
488
  if column.referenced_columns:
480
489
  for stream_name, referenced_columns in column.referenced_columns.items():
@@ -485,8 +494,6 @@ class SnowflakeViewParts(BaseModel):
485
494
  if join.join_stream_name not in all_referenced_columns:
486
495
  all_referenced_columns[join.join_stream_name] = []
487
496
  all_referenced_columns[join.join_stream_name].append(join.join_stream_column)
488
- if part.stream_name not in all_referenced_columns:
489
- all_referenced_columns[part.stream_name] = []
490
497
  all_referenced_columns[part.stream_name].append(join.left_column)
491
498
 
492
499
 
@@ -574,8 +581,8 @@ class SnowflakeViewParts(BaseModel):
574
581
  # We need to check both by stream name and by join stream alias
575
582
 
576
583
  # Build mappings for stream names and aliases
577
- stream_to_aliases = {} # stream_name -> set of aliases
578
- alias_to_stream = {} # alias -> stream_name
584
+ stream_to_aliases:Dict[str,set] = {} # stream_name -> set of aliases
585
+ alias_to_stream:Dict[str,str] = {} # alias -> stream_name
579
586
 
580
587
  # Initialize with the main stream
581
588
  stream_to_aliases[main_stream_view_part.stream_name] = {main_stream_view_part.stream_name}
@@ -586,7 +593,7 @@ class SnowflakeViewParts(BaseModel):
586
593
  logger.debug(f"Processing joins for stream: {part.stream_name}")
587
594
  # Make sure the part's stream name is in the mappings
588
595
  if part.stream_name not in stream_to_aliases:
589
- stream_to_aliases[part.stream_name] = {part.stream_name}
596
+ stream_to_aliases[part.stream_name] = [part.stream_name]
590
597
  alias_to_stream[part.stream_name] = part.stream_name
591
598
 
592
599
  for join in part.joins:
@@ -610,7 +617,7 @@ class SnowflakeViewParts(BaseModel):
610
617
  break
611
618
 
612
619
  # Build a graph of references between streams and their aliases
613
- circular_refs = {} # (source, target) -> [(column_name, ref_fields)]
620
+ circular_refs:Dict[Tuple[str,str],List[Tuple[str,List[str]]]] = {} # (source, target) -> [(column_name, ref_fields)]
614
621
 
615
622
  # First, add references based on column dependencies
616
623
  for part in [main_stream_view_part] + joined_parts:
@@ -775,7 +782,19 @@ def prune(view_part: SnowflakeViewPart, joined_parts: List[SnowflakeViewPart]) -
775
782
 
776
783
  # Process joined parts
777
784
  for joined_part in joined_parts:
785
+ # We have to avoid pruning columns that are referenced by joins to this stream.
786
+ # first, we determine all aliases for this stream (multiple join paths back to the same stream are allowed)
787
+ aliases_for_stream = [j.join_stream_alias for j in view_part.joins if j.join_stream_name == joined_part.stream_name]
788
+ # now find all joins using this stream as the join stream
789
+ columns_used_in_joins = [
790
+ j.left_column for j in view_part.joins if j.left_alias in aliases_for_stream
791
+ ]
778
792
  for column in joined_part.columns[:]: # Use a copy to allow safe removal
793
+ # First check if the column is a join column
794
+ if column.original_name in columns_used_in_joins:
795
+ # If it's a join column, we need to keep it
796
+ continue
797
+
779
798
  if not should_keep_column(column, joined_part):
780
799
  joined_part.columns.remove(column)
781
800
  columns_removed = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.10.25
3
+ Version: 0.10.26
4
4
  Summary: Classes and common runtime components for building and running Omnata Plugins
5
5
  Author: James Weakley
6
6
  Author-email: james.weakley@omnata.com
@@ -2,12 +2,12 @@ omnata_plugin_runtime/__init__.py,sha256=MS9d1whnfT_B3-ThqZ7l63QeC_8OEKTuaYV5wTw
2
2
  omnata_plugin_runtime/api.py,sha256=baGraSMiD4Yvi3ZWrEv_TKh8Ktd1U8riBdOpe9j0Puw,8202
3
3
  omnata_plugin_runtime/configuration.py,sha256=ud3O9R03BbUjGUJDVpGbnADqKw5oLVy65EQN1g6gmKg,46811
4
4
  omnata_plugin_runtime/forms.py,sha256=Lrbr3otsFDrvHWJw7v-slsW4PvEHJ6BG1Yl8oaJfiDo,20529
5
- omnata_plugin_runtime/json_schema.py,sha256=rqpJ5wjZiaE6shFB6Rv5CRHIl8xGxntibNjlh4A6Zr0,45902
5
+ omnata_plugin_runtime/json_schema.py,sha256=Mq1R_TAYklG92iDUmeZFdjuUr-PEoejIXNs6hICyOgc,47196
6
6
  omnata_plugin_runtime/logging.py,sha256=WBuZt8lF9E5oFWM4KYQbE8dDJ_HctJ1pN3BHwU6rcd0,4461
7
7
  omnata_plugin_runtime/omnata_plugin.py,sha256=vD6FKJIFzTRYbj1Q51LSE-Kar4GPTq9SJcBU5jCYtiQ,134074
8
8
  omnata_plugin_runtime/plugin_entrypoints.py,sha256=SlpI3VF3EdTGFCr9wDD0kV4v6B6bHfNDFdC3slU2y8Y,32241
9
9
  omnata_plugin_runtime/rate_limiting.py,sha256=qpr5esU4Ks8hMzuMpSR3gLFdor2ZUXYWCjmsQH_K6lQ,25882
10
- omnata_plugin_runtime-0.10.25.dist-info/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
11
- omnata_plugin_runtime-0.10.25.dist-info/METADATA,sha256=n2fp4xzWD8fLZumTMPNwmtylqwtFRNBKIaLQDsC8t-c,2208
12
- omnata_plugin_runtime-0.10.25.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
13
- omnata_plugin_runtime-0.10.25.dist-info/RECORD,,
10
+ omnata_plugin_runtime-0.10.26.dist-info/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
11
+ omnata_plugin_runtime-0.10.26.dist-info/METADATA,sha256=g6r33zwplvtOzmX701x1c6VFKZOkHrdm9_oEJxTH5xg,2208
12
+ omnata_plugin_runtime-0.10.26.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
13
+ omnata_plugin_runtime-0.10.26.dist-info/RECORD,,