omnata-plugin-runtime 0.10.5a234__py3-none-any.whl → 0.10.6__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.
- omnata_plugin_runtime/json_schema.py +49 -15
- {omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6.dist-info}/METADATA +1 -1
- {omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6.dist-info}/RECORD +5 -5
- {omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6.dist-info}/LICENSE +0 -0
- {omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6.dist-info}/WHEEL +0 -0
@@ -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,8 +173,17 @@ 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}"'
|
184
|
+
|
185
|
+
def original_to_transformed(self) -> str:
|
186
|
+
return f'"{self.original_name}" as "{self.name}"'
|
175
187
|
|
176
188
|
def name_with_comment(self,binding_list:Optional[List[Any]] = None) -> str:
|
177
189
|
"""
|
@@ -222,6 +234,7 @@ class SnowflakeViewColumn(BaseModel):
|
|
222
234
|
required_stream_names = json_schema_property.requiredStreamNames
|
223
235
|
return cls(
|
224
236
|
name=final_column_name,
|
237
|
+
original_name=column_name,
|
225
238
|
expression=expression,
|
226
239
|
comment=comment,
|
227
240
|
is_join_column=json_schema_property.isJoinColumn,
|
@@ -240,10 +253,10 @@ class SnowflakeViewColumn(BaseModel):
|
|
240
253
|
columns_to_move:List[Self] = []
|
241
254
|
for column in join_columns:
|
242
255
|
for other_column in join_columns:
|
243
|
-
if f'"{column.
|
256
|
+
if f'"{column.original_name}"' in other_column.expression:
|
244
257
|
if column not in columns_to_move:
|
245
258
|
columns_to_move.append(column)
|
246
|
-
|
259
|
+
|
247
260
|
# Move collected columns to the front
|
248
261
|
for column in columns_to_move:
|
249
262
|
join_columns.remove(column)
|
@@ -356,7 +369,7 @@ class SnowflakeViewPart(BaseModel):
|
|
356
369
|
"""
|
357
370
|
Returns the columns that are not sourced from joins.
|
358
371
|
"""
|
359
|
-
return [c for c in self.columns if not c.is_join_column]
|
372
|
+
return SnowflakeViewColumn.order_by_reference([c for c in self.columns if not c.is_join_column])
|
360
373
|
|
361
374
|
def join_columns(self) -> List[SnowflakeViewColumn]:
|
362
375
|
"""
|
@@ -383,12 +396,12 @@ class SnowflakeViewPart(BaseModel):
|
|
383
396
|
c.name_with_comment(binding_list) for c in (self.direct_columns() + self.join_columns())
|
384
397
|
]
|
385
398
|
|
386
|
-
def cte_text(self) -> str:
|
399
|
+
def cte_text(self,original_name: bool = False) -> str:
|
387
400
|
"""
|
388
401
|
Returns the CTE text for this view part.
|
389
402
|
"""
|
390
403
|
return f""" "{self.stream_name}" as (
|
391
|
-
select {', '.join([c.definition() for c in self.direct_columns()])}
|
404
|
+
select {', '.join([c.definition(original_name=original_name) for c in self.direct_columns()])}
|
392
405
|
from {self.raw_table_location.get_fully_qualified_name()}
|
393
406
|
) """
|
394
407
|
|
@@ -407,17 +420,33 @@ class SnowflakeViewParts(BaseModel):
|
|
407
420
|
|
408
421
|
def view_body(self):
|
409
422
|
"""
|
410
|
-
Creates a view definition from the parts
|
411
|
-
|
412
|
-
|
423
|
+
Creates a view definition from the parts.
|
424
|
+
The view will consist of CTEs for all of the involved streams, and these will use their original column names without transformation.
|
425
|
+
There will be a final SELECT statement that selects all columns from the main stream, and then adds any columns obtained via joins.
|
426
|
+
In the final select statement, the join columns will be aliased with their transformed names.
|
427
|
+
"""
|
428
|
+
ctes = [self.main_part.cte_text(original_name=True)] + [part.cte_text(original_name=True) for part in self.joined_parts]
|
429
|
+
# we need a final CTE which selects the main part's direct columns and joined columns, with their original names
|
430
|
+
# then the final select statement will just be aliasing to the transformed names
|
431
|
+
final_cte = f""" OMNATA_FINAL_CTE as (
|
432
|
+
select {', '.join(
|
433
|
+
[
|
434
|
+
f'"{c.original_name}"' for c in self.main_part.direct_columns()
|
435
|
+
]+[
|
436
|
+
c.definition(original_name=True) for c in self.main_part.join_columns()
|
437
|
+
])}
|
438
|
+
from "{self.main_part.stream_name}"
|
439
|
+
) """
|
440
|
+
ctes.append(final_cte)
|
413
441
|
all_ctes = "\n,".join(ctes)
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
442
|
+
main_columns:List[SnowflakeViewColumn] = SnowflakeViewColumn.order_by_reference(self.main_part.direct_columns() +
|
443
|
+
self.main_part.join_columns())
|
444
|
+
column_clauses = [f"\"OMNATA_FINAL_CTE\"."+c.original_to_transformed()
|
445
|
+
for c in main_columns]
|
446
|
+
|
418
447
|
view_body = f"""with {all_ctes}
|
419
|
-
select {', '.join(
|
420
|
-
from
|
448
|
+
select {', '.join(column_clauses)}
|
449
|
+
from OMNATA_FINAL_CTE """
|
421
450
|
if len(self.main_part.joins) > 0:
|
422
451
|
join_clauses = [join.definition() for join in self.main_part.joins]
|
423
452
|
view_body += "\n" + ("\n".join(join_clauses))
|
@@ -584,6 +613,7 @@ def normalized_view_part(
|
|
584
613
|
snowflake_columns.append(
|
585
614
|
SnowflakeViewColumn(
|
586
615
|
name="OMNATA_APP_IDENTIFIER",
|
616
|
+
original_name="OMNATA_APP_IDENTIFIER",
|
587
617
|
expression="APP_IDENTIFIER",
|
588
618
|
comment="The value of the unique identifier for the record in the source system",
|
589
619
|
)
|
@@ -591,6 +621,7 @@ def normalized_view_part(
|
|
591
621
|
snowflake_columns.append(
|
592
622
|
SnowflakeViewColumn(
|
593
623
|
name="OMNATA_RETRIEVE_DATE",
|
624
|
+
original_name="OMNATA_RETRIEVE_DATE",
|
594
625
|
expression="RETRIEVE_DATE",
|
595
626
|
comment="The date and time the record was retrieved from the source system",
|
596
627
|
)
|
@@ -598,6 +629,7 @@ def normalized_view_part(
|
|
598
629
|
snowflake_columns.append(
|
599
630
|
SnowflakeViewColumn(
|
600
631
|
name="OMNATA_RAW_RECORD",
|
632
|
+
original_name="OMNATA_RAW_RECORD",
|
601
633
|
expression="RECORD_DATA",
|
602
634
|
comment="The raw semi-structured record as retrieved from the source system",
|
603
635
|
)
|
@@ -605,6 +637,7 @@ def normalized_view_part(
|
|
605
637
|
snowflake_columns.append(
|
606
638
|
SnowflakeViewColumn(
|
607
639
|
name="OMNATA_IS_DELETED",
|
640
|
+
original_name="OMNATA_IS_DELETED",
|
608
641
|
expression="IS_DELETED",
|
609
642
|
comment="A flag to indicate that the record was deleted from the source system",
|
610
643
|
)
|
@@ -612,6 +645,7 @@ def normalized_view_part(
|
|
612
645
|
snowflake_columns.append(
|
613
646
|
SnowflakeViewColumn(
|
614
647
|
name="OMNATA_RUN_ID",
|
648
|
+
original_name="OMNATA_RUN_ID",
|
615
649
|
expression="RUN_ID",
|
616
650
|
comment="A flag to indicate which run the record was last processed in",
|
617
651
|
)
|
{omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6.dist-info}/RECORD
RENAMED
@@ -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=
|
5
|
+
omnata_plugin_runtime/json_schema.py,sha256=0_9V-7nmNemgNxnvKPfK72RmBiQGex-bmAkPsiAgMi4,30370
|
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.
|
11
|
-
omnata_plugin_runtime-0.10.
|
12
|
-
omnata_plugin_runtime-0.10.
|
13
|
-
omnata_plugin_runtime-0.10.
|
10
|
+
omnata_plugin_runtime-0.10.6.dist-info/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
|
11
|
+
omnata_plugin_runtime-0.10.6.dist-info/METADATA,sha256=a_oDqZNINWw6qknG_tU1p7WfZpz0nzL_DhZZVY71Spo,2207
|
12
|
+
omnata_plugin_runtime-0.10.6.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
13
|
+
omnata_plugin_runtime-0.10.6.dist-info/RECORD,,
|
{omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6.dist-info}/LICENSE
RENAMED
File without changes
|
File without changes
|