omnata-plugin-runtime 0.10.7a254__tar.gz → 0.10.8a255__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.10.7a254
3
+ Version: 0.10.8a255
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "omnata-plugin-runtime"
3
- version = "0.10.7-a254"
3
+ version = "0.10.8-a255"
4
4
  description = "Classes and common runtime components for building and running Omnata Plugins"
5
5
  authors = ["James Weakley <james.weakley@omnata.com>"]
6
6
  readme = "README.md"
@@ -52,6 +52,9 @@ class JsonSchemaProperty(BaseModel):
52
52
  requiredStreamNames: Optional[List[str]] = Field(
53
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
54
  )
55
+ referencedFields: Optional[Dict[str,List[str]]] = Field(
56
+ None, description="The names of fields that are referenced by this field, keyed on the stream name (or None if it's the current stream). This is used to order the fields, and also to cascade the removal of unsupported fields (e.g. in formulas)."
57
+ )
55
58
 
56
59
  @model_validator(mode='after')
57
60
  def validate(self) -> Self:
@@ -165,6 +168,9 @@ class SnowflakeViewColumn(BaseModel):
165
168
  required_stream_names: Optional[List[str]] = Field(
166
169
  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"
167
170
  )
171
+ referenced_columns: Optional[Dict[str,List[str]]] = Field(
172
+ default=None, description="The names of columns that are referenced by this column, keyed on the stream name (or None if it's the current stream). This is used to order the columns, and also to cascade the removal of unsupported columns (e.g. in formulas)."
173
+ )
168
174
 
169
175
  def __repr__(self) -> str:
170
176
  return "SnowflakeViewColumn(name=%r, definition=%r, comment=%r)" % (
@@ -230,19 +236,23 @@ class SnowflakeViewColumn(BaseModel):
230
236
  if not json_schema_property.snowflakeColumnExpression:
231
237
  expression=f"""{expression}::{json_schema_property.snowflake_data_type}"""
232
238
  required_stream_names = None
239
+ referenced_columns = None
233
240
  if json_schema_property.requiredStreamNames:
234
241
  required_stream_names = json_schema_property.requiredStreamNames
242
+ if json_schema_property.referencedFields:
243
+ referenced_columns = json_schema_property.referencedFields
235
244
  return cls(
236
245
  name=final_column_name,
237
246
  original_name=column_name,
238
247
  expression=expression,
239
248
  comment=comment,
240
249
  is_join_column=json_schema_property.isJoinColumn,
241
- required_stream_names=required_stream_names
250
+ required_stream_names=required_stream_names,
251
+ referenced_columns=referenced_columns
242
252
  )
243
253
 
244
254
  @classmethod
245
- def order_by_reference(cls,columns:List[Self]) -> List[Self]:
255
+ def order_by_reference(cls,current_stream_name:str,columns:List[Self]) -> List[Self]:
246
256
  """
247
257
  In some situations, column expressions may reference the alias of another column
248
258
  This is allowed in Snowflake, as long as the aliased column is defined before it's used in a later column
@@ -262,7 +272,7 @@ class SnowflakeViewColumn(BaseModel):
262
272
  for other_column in columns:
263
273
  if column==other_column:
264
274
  continue
265
- if f'"{column.original_name}"' in other_column.expression:
275
+ if column.original_name in (other_column.referenced_columns or {}).get(current_stream_name,[]):
266
276
  if column not in columns_to_move:
267
277
  columns_to_move.append(column)
268
278
 
@@ -679,7 +689,7 @@ def normalized_view_part(
679
689
  #- APP_IDENTIFIER
680
690
  #- Direct and joined columns, ordered so that columns that reference other columns are defined after the columns they reference
681
691
  #- OMNATA_RETRIEVE_DATE, OMNATA_RAW_RECORD, OMNATA_IS_DELETED, OMNATA_RUN_ID
682
- view_columns = SnowflakeViewColumn.order_by_reference(direct_view_columns +
692
+ view_columns = SnowflakeViewColumn.order_by_reference(stream_name,direct_view_columns +
683
693
  join_view_columns)
684
694
  return SnowflakeViewPart(
685
695
  stream_name=stream_name,