omnata-plugin-runtime 0.10.5a234__py3-none-any.whl → 0.10.6a236__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 +28 -8
- {omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6a236.dist-info}/METADATA +1 -1
- {omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6a236.dist-info}/RECORD +5 -5
- {omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6a236.dist-info}/LICENSE +0 -0
- {omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6a236.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,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
|
-
|
416
|
-
|
417
|
-
|
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}" """
|
@@ -584,6 +599,7 @@ def normalized_view_part(
|
|
584
599
|
snowflake_columns.append(
|
585
600
|
SnowflakeViewColumn(
|
586
601
|
name="OMNATA_APP_IDENTIFIER",
|
602
|
+
original_name="OMNATA_APP_IDENTIFIER",
|
587
603
|
expression="APP_IDENTIFIER",
|
588
604
|
comment="The value of the unique identifier for the record in the source system",
|
589
605
|
)
|
@@ -591,6 +607,7 @@ def normalized_view_part(
|
|
591
607
|
snowflake_columns.append(
|
592
608
|
SnowflakeViewColumn(
|
593
609
|
name="OMNATA_RETRIEVE_DATE",
|
610
|
+
original_name="OMNATA_RETRIEVE_DATE",
|
594
611
|
expression="RETRIEVE_DATE",
|
595
612
|
comment="The date and time the record was retrieved from the source system",
|
596
613
|
)
|
@@ -598,6 +615,7 @@ def normalized_view_part(
|
|
598
615
|
snowflake_columns.append(
|
599
616
|
SnowflakeViewColumn(
|
600
617
|
name="OMNATA_RAW_RECORD",
|
618
|
+
original_name="OMNATA_RAW_RECORD",
|
601
619
|
expression="RECORD_DATA",
|
602
620
|
comment="The raw semi-structured record as retrieved from the source system",
|
603
621
|
)
|
@@ -605,6 +623,7 @@ def normalized_view_part(
|
|
605
623
|
snowflake_columns.append(
|
606
624
|
SnowflakeViewColumn(
|
607
625
|
name="OMNATA_IS_DELETED",
|
626
|
+
original_name="OMNATA_IS_DELETED",
|
608
627
|
expression="IS_DELETED",
|
609
628
|
comment="A flag to indicate that the record was deleted from the source system",
|
610
629
|
)
|
@@ -612,6 +631,7 @@ def normalized_view_part(
|
|
612
631
|
snowflake_columns.append(
|
613
632
|
SnowflakeViewColumn(
|
614
633
|
name="OMNATA_RUN_ID",
|
634
|
+
original_name="OMNATA_RUN_ID",
|
615
635
|
expression="RUN_ID",
|
616
636
|
comment="A flag to indicate which run the record was last processed in",
|
617
637
|
)
|
{omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6a236.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=WJ3I7UORtVOLMDgtu6U8ZH7NuZoTGpJ9bFueyshgVjg,29739
|
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.6a236.dist-info/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
|
11
|
+
omnata_plugin_runtime-0.10.6a236.dist-info/METADATA,sha256=YniIppQo7-RJ4lfGmJAWGWMlj--9bQSroXCMPYL7k1U,2211
|
12
|
+
omnata_plugin_runtime-0.10.6a236.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
13
|
+
omnata_plugin_runtime-0.10.6a236.dist-info/RECORD,,
|
{omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6a236.dist-info}/LICENSE
RENAMED
File without changes
|
{omnata_plugin_runtime-0.10.5a234.dist-info → omnata_plugin_runtime-0.10.6a236.dist-info}/WHEEL
RENAMED
File without changes
|