airbyte-cdk 6.45.2.post3.dev14463482961__py3-none-any.whl → 6.45.3__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.
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml +26 -0
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py +24 -0
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +12 -0
- airbyte_cdk/sources/declarative/transformations/dpath_flatten_fields.py +41 -2
- {airbyte_cdk-6.45.2.post3.dev14463482961.dist-info → airbyte_cdk-6.45.3.dist-info}/METADATA +1 -1
- {airbyte_cdk-6.45.2.post3.dev14463482961.dist-info → airbyte_cdk-6.45.3.dist-info}/RECORD +10 -10
- {airbyte_cdk-6.45.2.post3.dev14463482961.dist-info → airbyte_cdk-6.45.3.dist-info}/LICENSE.txt +0 -0
- {airbyte_cdk-6.45.2.post3.dev14463482961.dist-info → airbyte_cdk-6.45.3.dist-info}/LICENSE_SHORT +0 -0
- {airbyte_cdk-6.45.2.post3.dev14463482961.dist-info → airbyte_cdk-6.45.3.dist-info}/WHEEL +0 -0
- {airbyte_cdk-6.45.2.post3.dev14463482961.dist-info → airbyte_cdk-6.45.3.dist-info}/entry_points.txt +0 -0
@@ -2307,6 +2307,27 @@ definitions:
|
|
2307
2307
|
$parameters:
|
2308
2308
|
type: object
|
2309
2309
|
additionalProperties: true
|
2310
|
+
KeyTransformation:
|
2311
|
+
title: Transformation to apply for extracted object keys by Dpath Flatten Fields
|
2312
|
+
type: object
|
2313
|
+
required:
|
2314
|
+
- type
|
2315
|
+
properties:
|
2316
|
+
type:
|
2317
|
+
type: string
|
2318
|
+
enum: [ KeyTransformation ]
|
2319
|
+
prefix:
|
2320
|
+
title: Key Prefix
|
2321
|
+
description: Prefix to add for object keys. If not provided original keys remain unchanged.
|
2322
|
+
type: string
|
2323
|
+
examples:
|
2324
|
+
- flattened_
|
2325
|
+
suffix:
|
2326
|
+
title: Key Suffix
|
2327
|
+
description: Suffix to add for object keys. If not provided original keys remain unchanged.
|
2328
|
+
type: string
|
2329
|
+
examples:
|
2330
|
+
- _flattened
|
2310
2331
|
DpathFlattenFields:
|
2311
2332
|
title: Dpath Flatten Fields
|
2312
2333
|
description: A transformation that flatten field values to the to top of the record.
|
@@ -2335,6 +2356,11 @@ definitions:
|
|
2335
2356
|
title: Replace Origin Record
|
2336
2357
|
description: Whether to replace the origin record or not. Default is False.
|
2337
2358
|
type: boolean
|
2359
|
+
key_transformation:
|
2360
|
+
title: Key transformation
|
2361
|
+
description: Transformation for object keys. If not provided, original key will be used.
|
2362
|
+
type: object
|
2363
|
+
"$ref": "#/definitions/KeyTransformation"
|
2338
2364
|
$parameters:
|
2339
2365
|
type: object
|
2340
2366
|
additionalProperties: true
|
@@ -879,6 +879,25 @@ class FlattenFields(BaseModel):
|
|
879
879
|
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
|
880
880
|
|
881
881
|
|
882
|
+
class KeyTransformation(BaseModel):
|
883
|
+
prefix: Optional[Union[str, None]] = Field(
|
884
|
+
None,
|
885
|
+
description="Prefix to add for object keys. If not provided original keys remain unchanged.",
|
886
|
+
examples=[
|
887
|
+
"flattened_",
|
888
|
+
],
|
889
|
+
title="Key Prefix",
|
890
|
+
)
|
891
|
+
suffix: Optional[Union[str, None]] = Field(
|
892
|
+
None,
|
893
|
+
description="Suffix to add for object keys. If not provided original keys remain unchanged.",
|
894
|
+
examples=[
|
895
|
+
"_flattened",
|
896
|
+
],
|
897
|
+
title="Key Suffix",
|
898
|
+
)
|
899
|
+
|
900
|
+
|
882
901
|
class DpathFlattenFields(BaseModel):
|
883
902
|
type: Literal["DpathFlattenFields"]
|
884
903
|
field_path: List[str] = Field(
|
@@ -897,6 +916,11 @@ class DpathFlattenFields(BaseModel):
|
|
897
916
|
description="Whether to replace the origin record or not. Default is False.",
|
898
917
|
title="Replace Origin Record",
|
899
918
|
)
|
919
|
+
key_transformation: Optional[Union[KeyTransformation, None]] = Field(
|
920
|
+
None,
|
921
|
+
description="Transformation for object keys. If not provided, original key will be used.",
|
922
|
+
title="Key transformation",
|
923
|
+
)
|
900
924
|
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
|
901
925
|
|
902
926
|
|
@@ -498,6 +498,7 @@ from airbyte_cdk.sources.declarative.transformations import (
|
|
498
498
|
from airbyte_cdk.sources.declarative.transformations.add_fields import AddedFieldDefinition
|
499
499
|
from airbyte_cdk.sources.declarative.transformations.dpath_flatten_fields import (
|
500
500
|
DpathFlattenFields,
|
501
|
+
KeyTransformation,
|
501
502
|
)
|
502
503
|
from airbyte_cdk.sources.declarative.transformations.flatten_fields import (
|
503
504
|
FlattenFields,
|
@@ -790,6 +791,16 @@ class ModelToComponentFactory:
|
|
790
791
|
self, model: DpathFlattenFieldsModel, config: Config, **kwargs: Any
|
791
792
|
) -> DpathFlattenFields:
|
792
793
|
model_field_path: List[Union[InterpolatedString, str]] = [x for x in model.field_path]
|
794
|
+
key_transformation = (
|
795
|
+
KeyTransformation(
|
796
|
+
config=config,
|
797
|
+
prefix=model.key_transformation.prefix,
|
798
|
+
suffix=model.key_transformation.suffix,
|
799
|
+
parameters=model.parameters or {},
|
800
|
+
)
|
801
|
+
if model.key_transformation is not None
|
802
|
+
else None
|
803
|
+
)
|
793
804
|
return DpathFlattenFields(
|
794
805
|
config=config,
|
795
806
|
field_path=model_field_path,
|
@@ -797,6 +808,7 @@ class ModelToComponentFactory:
|
|
797
808
|
if model.delete_origin_value is not None
|
798
809
|
else False,
|
799
810
|
replace_record=model.replace_record if model.replace_record is not None else False,
|
811
|
+
key_transformation=key_transformation,
|
800
812
|
parameters=model.parameters or {},
|
801
813
|
)
|
802
814
|
|
@@ -8,6 +8,24 @@ from airbyte_cdk.sources.declarative.transformations import RecordTransformation
|
|
8
8
|
from airbyte_cdk.sources.types import Config, StreamSlice, StreamState
|
9
9
|
|
10
10
|
|
11
|
+
@dataclass
|
12
|
+
class KeyTransformation:
|
13
|
+
config: Config
|
14
|
+
parameters: InitVar[Mapping[str, Any]]
|
15
|
+
prefix: Optional[str] = None
|
16
|
+
suffix: Optional[str] = None
|
17
|
+
|
18
|
+
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
|
19
|
+
if self.prefix is not None:
|
20
|
+
self.prefix = InterpolatedString.create(self.prefix, parameters=parameters).eval(
|
21
|
+
self.config
|
22
|
+
)
|
23
|
+
if self.suffix is not None:
|
24
|
+
self.suffix = InterpolatedString.create(self.suffix, parameters=parameters).eval(
|
25
|
+
self.config
|
26
|
+
)
|
27
|
+
|
28
|
+
|
11
29
|
@dataclass
|
12
30
|
class DpathFlattenFields(RecordTransformation):
|
13
31
|
"""
|
@@ -16,6 +34,7 @@ class DpathFlattenFields(RecordTransformation):
|
|
16
34
|
field_path: List[Union[InterpolatedString, str]] path to the field to flatten.
|
17
35
|
delete_origin_value: bool = False whether to delete origin field or keep it. Default is False.
|
18
36
|
replace_record: bool = False whether to replace origin record or not. Default is False.
|
37
|
+
key_transformation: KeyTransformation = None how to transform extracted object keys
|
19
38
|
|
20
39
|
"""
|
21
40
|
|
@@ -24,17 +43,35 @@ class DpathFlattenFields(RecordTransformation):
|
|
24
43
|
parameters: InitVar[Mapping[str, Any]]
|
25
44
|
delete_origin_value: bool = False
|
26
45
|
replace_record: bool = False
|
46
|
+
key_transformation: Optional[KeyTransformation] = None
|
27
47
|
|
28
48
|
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
|
49
|
+
self._parameters = parameters
|
29
50
|
self._field_path = [
|
30
|
-
InterpolatedString.create(path, parameters=
|
51
|
+
InterpolatedString.create(path, parameters=self._parameters) for path in self.field_path
|
31
52
|
]
|
32
53
|
for path_index in range(len(self.field_path)):
|
33
54
|
if isinstance(self.field_path[path_index], str):
|
34
55
|
self._field_path[path_index] = InterpolatedString.create(
|
35
|
-
self.field_path[path_index], parameters=
|
56
|
+
self.field_path[path_index], parameters=self._parameters
|
36
57
|
)
|
37
58
|
|
59
|
+
def _apply_key_transformation(self, extracted: Mapping[str, Any]) -> Mapping[str, Any]:
|
60
|
+
if self.key_transformation:
|
61
|
+
if self.key_transformation.prefix:
|
62
|
+
extracted = {
|
63
|
+
f"{self.key_transformation.prefix}{key}": value
|
64
|
+
for key, value in extracted.items()
|
65
|
+
}
|
66
|
+
|
67
|
+
if self.key_transformation.suffix:
|
68
|
+
extracted = {
|
69
|
+
f"{key}{self.key_transformation.suffix}": value
|
70
|
+
for key, value in extracted.items()
|
71
|
+
}
|
72
|
+
|
73
|
+
return extracted
|
74
|
+
|
38
75
|
def transform(
|
39
76
|
self,
|
40
77
|
record: Dict[str, Any],
|
@@ -50,6 +87,8 @@ class DpathFlattenFields(RecordTransformation):
|
|
50
87
|
extracted = dpath.get(record, path, default=[])
|
51
88
|
|
52
89
|
if isinstance(extracted, dict):
|
90
|
+
extracted = self._apply_key_transformation(extracted)
|
91
|
+
|
53
92
|
if self.replace_record and extracted:
|
54
93
|
dpath.delete(record, "**")
|
55
94
|
record.update(extracted)
|
@@ -71,7 +71,7 @@ airbyte_cdk/sources/declarative/concurrent_declarative_source.py,sha256=uhy0dRkA
|
|
71
71
|
airbyte_cdk/sources/declarative/datetime/__init__.py,sha256=4Hw-PX1-VgESLF16cDdvuYCzGJtHntThLF4qIiULWeo,61
|
72
72
|
airbyte_cdk/sources/declarative/datetime/datetime_parser.py,sha256=_zGNGq31RNy_0QBLt_EcTvgPyhj7urPdx6oA3M5-r3o,3150
|
73
73
|
airbyte_cdk/sources/declarative/datetime/min_max_datetime.py,sha256=0BHBtDNQZfvwM45-tY5pNlTcKAFSGGNxemoi0Jic-0E,5785
|
74
|
-
airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=
|
74
|
+
airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=GKYtd8sQfL5_g4y02QEv0sTQrUFU1HypExKFG6YwB2E,159019
|
75
75
|
airbyte_cdk/sources/declarative/declarative_source.py,sha256=nF7wBqFd3AQmEKAm4CnIo29CJoQL562cJGSCeL8U8bA,1531
|
76
76
|
airbyte_cdk/sources/declarative/declarative_stream.py,sha256=dCRlddBUSaJmBNBz1pSO1r2rTw8AP5d2_vlmIeGs2gg,10767
|
77
77
|
airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=JHb_0d3SE6kNY10mxA5YBEKPeSbsWYjByq1gUQxepoE,953
|
@@ -114,13 +114,13 @@ airbyte_cdk/sources/declarative/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW
|
|
114
114
|
airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py,sha256=iemy3fKLczcU0-Aor7tx5jcT6DRedKMqyK7kCOp01hg,3924
|
115
115
|
airbyte_cdk/sources/declarative/migrations/state_migration.py,sha256=KWPjealMLKSMtajXgkdGgKg7EmTLR-CqqD7UIh0-eDU,794
|
116
116
|
airbyte_cdk/sources/declarative/models/__init__.py,sha256=nUFxNCiKeYRVXuZEKA7GD-lTHxsiKcQ8FitZjKhPIvE,100
|
117
|
-
airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=
|
117
|
+
airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=04XDbonpVe1O3ek_TuRk96qfhQ0bcXeN7RQjysNGvAk,112782
|
118
118
|
airbyte_cdk/sources/declarative/parsers/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
|
119
119
|
airbyte_cdk/sources/declarative/parsers/custom_code_compiler.py,sha256=nlVvHC511NUyDEEIRBkoeDTAvLqKNp-hRy8D19z8tdk,5941
|
120
120
|
airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
|
121
121
|
airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=4C15MKV-zOrMVQAm4FyohDsrJUBCSpMv5tZw0SK3aeI,9685
|
122
122
|
airbyte_cdk/sources/declarative/parsers/manifest_reference_resolver.py,sha256=IWUOdF03o-aQn0Occo1BJCxU0Pz-QILk5L67nzw2thw,6803
|
123
|
-
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=
|
123
|
+
airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py,sha256=mgsar58RvTIhRjlgqjKaf7jOvDM5KiLhjkO7-w-x47I,159047
|
124
124
|
airbyte_cdk/sources/declarative/partition_routers/__init__.py,sha256=TBC9AkGaUqHm2IKHMPN6punBIcY5tWGULowcLoAVkfw,1109
|
125
125
|
airbyte_cdk/sources/declarative/partition_routers/async_job_partition_router.py,sha256=VelO7zKqKtzMJ35jyFeg0ypJLQC0plqqIBNXoBW1G2E,3001
|
126
126
|
airbyte_cdk/sources/declarative/partition_routers/cartesian_product_stream_slicer.py,sha256=c5cuVFM6NFkuQqG8Z5IwkBuwDrvXZN1CunUOM_L0ezg,6892
|
@@ -194,7 +194,7 @@ airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.p
|
|
194
194
|
airbyte_cdk/sources/declarative/stream_slicers/stream_slicer.py,sha256=SOkIPBi2Wu7yxIvA15yFzUAB95a3IzA8LPq5DEqHQQc,725
|
195
195
|
airbyte_cdk/sources/declarative/transformations/__init__.py,sha256=CPJ8TlMpiUmvG3624VYu_NfTzxwKcfBjM2Q2wJ7fkSA,919
|
196
196
|
airbyte_cdk/sources/declarative/transformations/add_fields.py,sha256=Eg1jQtRObgzxbtySTQs5uEZIjEklsoHFxYSPf78x6Ng,5420
|
197
|
-
airbyte_cdk/sources/declarative/transformations/dpath_flatten_fields.py,sha256=
|
197
|
+
airbyte_cdk/sources/declarative/transformations/dpath_flatten_fields.py,sha256=DO_zR2TqlvLTRO0c572xrleI4V-1QWVOEhbenGXVMLc,3811
|
198
198
|
airbyte_cdk/sources/declarative/transformations/flatten_fields.py,sha256=yT3owG6rMKaRX-LJ_T-jSTnh1B5NoAHyH4YZN9yOvE8,1758
|
199
199
|
airbyte_cdk/sources/declarative/transformations/keys_replace_transformation.py,sha256=vbIn6ump-Ut6g20yMub7PFoPBhOKVtrHSAUdcOUdLfw,1999
|
200
200
|
airbyte_cdk/sources/declarative/transformations/keys_to_lower_transformation.py,sha256=RTs5KX4V3hM7A6QN1WlGF21YccTIyNH6qQI9IMb__hw,670
|
@@ -366,9 +366,9 @@ airbyte_cdk/utils/slice_hasher.py,sha256=EDxgROHDbfG-QKQb59m7h_7crN1tRiawdf5uU7G
|
|
366
366
|
airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
|
367
367
|
airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
|
368
368
|
airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
|
369
|
-
airbyte_cdk-6.45.
|
370
|
-
airbyte_cdk-6.45.
|
371
|
-
airbyte_cdk-6.45.
|
372
|
-
airbyte_cdk-6.45.
|
373
|
-
airbyte_cdk-6.45.
|
374
|
-
airbyte_cdk-6.45.
|
369
|
+
airbyte_cdk-6.45.3.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
|
370
|
+
airbyte_cdk-6.45.3.dist-info/LICENSE_SHORT,sha256=aqF6D1NcESmpn-cqsxBtszTEnHKnlsp8L4x9wAh3Nxg,55
|
371
|
+
airbyte_cdk-6.45.3.dist-info/METADATA,sha256=wuKgATda_WotQz9zJ4tm3rTUGus73PALPun_UWt_iV0,6071
|
372
|
+
airbyte_cdk-6.45.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
373
|
+
airbyte_cdk-6.45.3.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
|
374
|
+
airbyte_cdk-6.45.3.dist-info/RECORD,,
|
{airbyte_cdk-6.45.2.post3.dev14463482961.dist-info → airbyte_cdk-6.45.3.dist-info}/LICENSE.txt
RENAMED
File without changes
|
{airbyte_cdk-6.45.2.post3.dev14463482961.dist-info → airbyte_cdk-6.45.3.dist-info}/LICENSE_SHORT
RENAMED
File without changes
|
File without changes
|
{airbyte_cdk-6.45.2.post3.dev14463482961.dist-info → airbyte_cdk-6.45.3.dist-info}/entry_points.txt
RENAMED
File without changes
|