omnata-plugin-runtime 0.10.3a229__py3-none-any.whl → 0.10.4a232__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.
@@ -7,6 +7,7 @@ from typing import Any, Dict, Optional, Literal, List, Union
7
7
  from typing_extensions import Self
8
8
  from pydantic import BaseModel, Field, model_validator, computed_field
9
9
  from jinja2 import Environment
10
+ from .logging import logger
10
11
 
11
12
  class JsonSchemaProperty(BaseModel):
12
13
  """
@@ -48,6 +49,9 @@ class JsonSchemaProperty(BaseModel):
48
49
  isJoinColumn: Optional[bool] = Field(
49
50
  False, description="Whether this column is sourced from a joined stream"
50
51
  )
52
+ requiredStreamNames: Optional[List[str]] = Field(
53
+ None, description="The names of the streams that are depended upon by this column, via joins. If these streams are not selected, the column will be omitted."
54
+ )
51
55
 
52
56
  @model_validator(mode='after')
53
57
  def validate(self) -> Self:
@@ -155,6 +159,9 @@ class SnowflakeViewColumn(BaseModel):
155
159
  is_join_column: Optional[bool] = Field(
156
160
  default=False, description="Whether this column is sourced from a joined stream"
157
161
  )
162
+ required_stream_names: Optional[List[str]] = Field(
163
+ default=None, description="The names of the streams that are depended upon by this column, via joins. If these streams are not selected, the column will be omitted"
164
+ )
158
165
 
159
166
  def __repr__(self) -> str:
160
167
  return "SnowflakeViewColumn(name=%r, definition=%r, comment=%r)" % (
@@ -210,11 +217,15 @@ class SnowflakeViewColumn(BaseModel):
210
217
  else:
211
218
  if not json_schema_property.snowflakeColumnExpression:
212
219
  expression=f"""{expression}::{json_schema_property.snowflake_data_type}"""
220
+ required_stream_names = None
221
+ if json_schema_property.requiredStreamNames:
222
+ required_stream_names = json_schema_property.requiredStreamNames
213
223
  return cls(
214
224
  name=final_column_name,
215
225
  expression=expression,
216
226
  comment=comment,
217
227
  is_join_column=json_schema_property.isJoinColumn,
228
+ required_stream_names=required_stream_names
218
229
  )
219
230
 
220
231
  @classmethod
@@ -435,11 +446,12 @@ class SnowflakeViewParts(BaseModel):
435
446
  column_name_expression=column_name_expression
436
447
  )
437
448
  joined_parts = []
449
+ # remove the joins from the main part if they are not in the raw stream locations
450
+ main_stream_view_part.joins = [join for join in main_stream_view_part.joins
451
+ if join.join_stream_name in raw_stream_locations
452
+ and join.join_stream_name in stream_schemas]
453
+
438
454
  for join in main_stream_view_part.joins:
439
- if join.join_stream_name not in raw_stream_locations:
440
- raise ValueError(f"Stream {join.join_stream_name} is required as a join for stream {stream_name}, but its location was not provided")
441
- if join.join_stream_name not in stream_schemas:
442
- raise ValueError(f"Stream {join.join_stream_name} is required as a join for stream {stream_name}, but its schema was not provided")
443
455
  joined_parts.append(normalized_view_part(
444
456
  stream_name=join.join_stream_name,
445
457
  raw_table_location=raw_stream_locations[join.join_stream_name],
@@ -448,6 +460,18 @@ class SnowflakeViewParts(BaseModel):
448
460
  column_name_environment=column_name_environment,
449
461
  column_name_expression=column_name_expression
450
462
  ))
463
+ # For each column, the plugin can advise which streams are required for the join, which comes through as required_stream_names
464
+ # on the SnowflakeViewColumn object.
465
+ # Until this generate function is called with the raw stream names, we don't know which streams the user has actually selected.
466
+ # So now there's a pruning process where we remove columns from the main view part that depend on streams that are not selected
467
+ for column in main_stream_view_part.columns:
468
+ if column.required_stream_names:
469
+ for required_stream_name in column.required_stream_names:
470
+ if required_stream_name not in raw_stream_locations:
471
+ logger.warning(f"Column {column.name} in stream {stream_name} requires stream {required_stream_name} to be selected, but it was not provided")
472
+ main_stream_view_part.columns.remove(column)
473
+ break
474
+
451
475
  return cls(main_part=main_stream_view_part, joined_parts=joined_parts)
452
476
 
453
477
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.10.3a229
3
+ Version: 0.10.4a232
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=f4ssL8ckqlG6vrUZEaX5SvirS4Tdrstl66ZZxVzBado,42457
4
4
  omnata_plugin_runtime/forms.py,sha256=9YHJ_T17lT-rwyDaUg_0yj_YMPda4DRCw_wrvf8hE0E,19964
5
- omnata_plugin_runtime/json_schema.py,sha256=7nsluzRHn5gmlV4V2G1ostOBstUuIbacBbQr3WsqGcU,26795
5
+ omnata_plugin_runtime/json_schema.py,sha256=NujSQBtyfnvSyw13sSFiSKmZeXkSk5cqCDVyuNwOACg,28395
6
6
  omnata_plugin_runtime/logging.py,sha256=WBuZt8lF9E5oFWM4KYQbE8dDJ_HctJ1pN3BHwU6rcd0,4461
7
7
  omnata_plugin_runtime/omnata_plugin.py,sha256=M0b6f9lKKEoEI0zf-ZwZcIPKPQTmHTIMhvcrBc94Mhg,133278
8
8
  omnata_plugin_runtime/plugin_entrypoints.py,sha256=iqGl8_nEEnPGKg3Aem4YLSQ6d5xS3ju5gq8MJbx6sCA,31968
9
9
  omnata_plugin_runtime/rate_limiting.py,sha256=qpr5esU4Ks8hMzuMpSR3gLFdor2ZUXYWCjmsQH_K6lQ,25882
10
- omnata_plugin_runtime-0.10.3a229.dist-info/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
11
- omnata_plugin_runtime-0.10.3a229.dist-info/METADATA,sha256=Y8Oz6art7zkZ2oQUgH8GuMe-Z5ZY9EVIlKqH825SaNI,2211
12
- omnata_plugin_runtime-0.10.3a229.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
13
- omnata_plugin_runtime-0.10.3a229.dist-info/RECORD,,
10
+ omnata_plugin_runtime-0.10.4a232.dist-info/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
11
+ omnata_plugin_runtime-0.10.4a232.dist-info/METADATA,sha256=WCUCnB2eC5KSI_p5qqL0W1JVUuhgbPXiXT86wA8wPNk,2211
12
+ omnata_plugin_runtime-0.10.4a232.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
13
+ omnata_plugin_runtime-0.10.4a232.dist-info/RECORD,,