omnata-plugin-runtime 0.10.5a234__py3-none-any.whl → 0.10.6a235__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.
@@ -154,6 +154,9 @@ class SnowflakeViewColumn(BaseModel):
154
154
  In other words, the column definition is "expression as name".
155
155
  """
156
156
  name: str
157
+ original_name: str = Field(
158
+ ..., description="The name of the column before the column naming transformation is applied"
159
+ )
157
160
  expression: str
158
161
  comment: Optional[str] = Field(default=None)
159
162
  is_join_column: Optional[bool] = Field(
@@ -170,7 +173,13 @@ class SnowflakeViewColumn(BaseModel):
170
173
  self.comment,
171
174
  )
172
175
 
173
- def definition(self) -> str:
176
+ def definition(self,original_name:bool = False) -> str:
177
+ """
178
+ Returns the column definition for a normalized view.
179
+ If original_name is True, the original name will be used instead of the transformed name.
180
+ """
181
+ if original_name:
182
+ return f'{self.expression} as "{self.original_name}"'
174
183
  return f'{self.expression} as "{self.name}"'
175
184
 
176
185
  def name_with_comment(self,binding_list:Optional[List[Any]] = None) -> str:
@@ -222,6 +231,7 @@ class SnowflakeViewColumn(BaseModel):
222
231
  required_stream_names = json_schema_property.requiredStreamNames
223
232
  return cls(
224
233
  name=final_column_name,
234
+ original_name=column_name,
225
235
  expression=expression,
226
236
  comment=comment,
227
237
  is_join_column=json_schema_property.isJoinColumn,
@@ -383,12 +393,12 @@ class SnowflakeViewPart(BaseModel):
383
393
  c.name_with_comment(binding_list) for c in (self.direct_columns() + self.join_columns())
384
394
  ]
385
395
 
386
- def cte_text(self) -> str:
396
+ def cte_text(self,original_name: bool = False) -> str:
387
397
  """
388
398
  Returns the CTE text for this view part.
389
399
  """
390
400
  return f""" "{self.stream_name}" as (
391
- select {', '.join([c.definition() for c in self.direct_columns()])}
401
+ select {', '.join([c.definition(original_name=original_name) for c in self.direct_columns()])}
392
402
  from {self.raw_table_location.get_fully_qualified_name()}
393
403
  ) """
394
404
 
@@ -407,14 +417,19 @@ class SnowflakeViewParts(BaseModel):
407
417
 
408
418
  def view_body(self):
409
419
  """
410
- Creates a view definition from the parts
420
+ Creates a view definition from the parts.
421
+ The view will consist of CTEs for all of the involved streams, and these will use their original column names without transformation.
422
+ There will be a final SELECT statement that selects all columns from the main stream, and then adds any columns obtained via joins.
423
+ In the final select statement, the join columns will be aliased with their transformed names.
411
424
  """
412
- ctes = [self.main_part.cte_text()] + [part.cte_text() for part in self.joined_parts]
425
+ ctes = [self.main_part.cte_text(original_name=True)] + [part.cte_text(original_name=True) for part in self.joined_parts]
413
426
  all_ctes = "\n,".join(ctes)
427
+ direct_columns = self.main_part.direct_columns()
414
428
  join_columns = self.main_part.join_columns()
415
- join_column_clauses = [c.definition() for c in join_columns]
416
- # we select * from the original view (in the CTE) and then add any expressions that come from the join columns
417
- final_column_clauses = [f'"{self.main_part.stream_name}".*'] + join_column_clauses
429
+ direct_column_clauses = [c.definition(original_name=True) for c in direct_columns]
430
+ join_column_clauses = [c.definition(original_name=False) for c in join_columns]
431
+ # the joined columns may reference the direct columns, so we need to order them correctly
432
+ final_column_clauses = direct_column_clauses + join_column_clauses
418
433
  view_body = f"""with {all_ctes}
419
434
  select {', '.join(final_column_clauses)}
420
435
  from "{self.main_part.stream_name}" """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.10.5a234
3
+ Version: 0.10.6a235
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=fpSyBr3Dr7GNdil88915VtMwRy5pexkGCRBk7BLFpPs,46527
4
4
  omnata_plugin_runtime/forms.py,sha256=9YHJ_T17lT-rwyDaUg_0yj_YMPda4DRCw_wrvf8hE0E,19964
5
- omnata_plugin_runtime/json_schema.py,sha256=NujSQBtyfnvSyw13sSFiSKmZeXkSk5cqCDVyuNwOACg,28395
5
+ omnata_plugin_runtime/json_schema.py,sha256=DB4bLNQ3mDvB8G0EQY2RiPwTe3H_PQKxa61ryTbpyEQ,29481
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.5a234.dist-info/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
11
- omnata_plugin_runtime-0.10.5a234.dist-info/METADATA,sha256=LsKz7fr8l-ZAnHw1azvxE0TgxN7X-_hov-IwFiZojys,2211
12
- omnata_plugin_runtime-0.10.5a234.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
13
- omnata_plugin_runtime-0.10.5a234.dist-info/RECORD,,
10
+ omnata_plugin_runtime-0.10.6a235.dist-info/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
11
+ omnata_plugin_runtime-0.10.6a235.dist-info/METADATA,sha256=CPI4nTz1LjXxvTejYOvdNe54rs-l8WEklh8e5H_C11c,2211
12
+ omnata_plugin_runtime-0.10.6a235.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
13
+ omnata_plugin_runtime-0.10.6a235.dist-info/RECORD,,