airbyte-cdk 6.18.0.dev0__py3-none-any.whl → 6.18.0.dev2__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 +16 -14
- airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py +29 -15
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py +10 -10
- {airbyte_cdk-6.18.0.dev0.dist-info → airbyte_cdk-6.18.0.dev2.dist-info}/METADATA +1 -1
- {airbyte_cdk-6.18.0.dev0.dist-info → airbyte_cdk-6.18.0.dev2.dist-info}/RECORD +8 -8
- {airbyte_cdk-6.18.0.dev0.dist-info → airbyte_cdk-6.18.0.dev2.dist-info}/LICENSE.txt +0 -0
- {airbyte_cdk-6.18.0.dev0.dist-info → airbyte_cdk-6.18.0.dev2.dist-info}/WHEEL +0 -0
- {airbyte_cdk-6.18.0.dev0.dist-info → airbyte_cdk-6.18.0.dev2.dist-info}/entry_points.txt +0 -0
@@ -2014,20 +2014,6 @@ definitions:
|
|
2014
2014
|
$parameters:
|
2015
2015
|
type: object
|
2016
2016
|
additionalProperties: true
|
2017
|
-
JsonParser:
|
2018
|
-
title: JsonParser
|
2019
|
-
description: Parser used for parsing str, bytes, or bytearray data and returning data in a dictionary format.
|
2020
|
-
type: object
|
2021
|
-
additionalProperties: true
|
2022
|
-
required:
|
2023
|
-
- type
|
2024
|
-
properties:
|
2025
|
-
type:
|
2026
|
-
type: string
|
2027
|
-
enum: [JsonParser]
|
2028
|
-
encoding:
|
2029
|
-
type: string
|
2030
|
-
default: utf-8
|
2031
2017
|
ListPartitionRouter:
|
2032
2018
|
title: List Partition Router
|
2033
2019
|
description: A Partition router that specifies a list of attributes where each attribute describes a portion of the complete data set for a stream. During a sync, each value is iterated over and can be used as input to outbound API requests.
|
@@ -2873,6 +2859,7 @@ definitions:
|
|
2873
2859
|
parser:
|
2874
2860
|
anyOf:
|
2875
2861
|
- "$ref": "#/definitions/GzipParser"
|
2862
|
+
- "$ref": "#/definitions/JsonParser"
|
2876
2863
|
- "$ref": "#/definitions/JsonLineParser"
|
2877
2864
|
- "$ref": "#/definitions/CsvParser"
|
2878
2865
|
# PARSERS
|
@@ -2889,6 +2876,21 @@ definitions:
|
|
2889
2876
|
anyOf:
|
2890
2877
|
- "$ref": "#/definitions/JsonLineParser"
|
2891
2878
|
- "$ref": "#/definitions/CsvParser"
|
2879
|
+
- "$ref": "#/definitions/JsonParser"
|
2880
|
+
JsonParser:
|
2881
|
+
title: JsonParser
|
2882
|
+
description: Parser used for parsing str, bytes, or bytearray data and returning data in a dictionary format.
|
2883
|
+
type: object
|
2884
|
+
additionalProperties: true
|
2885
|
+
required:
|
2886
|
+
- type
|
2887
|
+
properties:
|
2888
|
+
type:
|
2889
|
+
type: string
|
2890
|
+
enum: [JsonParser]
|
2891
|
+
encoding:
|
2892
|
+
type: string
|
2893
|
+
default: utf-8
|
2892
2894
|
JsonLineParser:
|
2893
2895
|
type: object
|
2894
2896
|
required:
|
@@ -7,6 +7,7 @@ from dataclasses import dataclass
|
|
7
7
|
from io import BufferedIOBase, TextIOWrapper
|
8
8
|
from typing import Any, Generator, MutableMapping, Optional
|
9
9
|
|
10
|
+
import orjson
|
10
11
|
import requests
|
11
12
|
|
12
13
|
from airbyte_cdk.models import FailureType
|
@@ -46,30 +47,43 @@ class GzipParser(Parser):
|
|
46
47
|
|
47
48
|
@dataclass
|
48
49
|
class JsonParser(Parser):
|
49
|
-
"""
|
50
|
-
Parser strategy for converting JSON-structure str, bytes, or bytearray data into MutableMapping[str, Any].
|
51
|
-
"""
|
52
|
-
|
53
50
|
encoding: str = "utf-8"
|
54
51
|
|
55
52
|
def parse(self, data: BufferedIOBase) -> Generator[MutableMapping[str, Any], None, None]:
|
53
|
+
"""
|
54
|
+
Attempts to deserialize data using orjson library. As an extra layer of safety we fallback on the json library to deserialize the data.
|
55
|
+
"""
|
56
56
|
raw_data = data.read()
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
|
58
|
+
body_json = self._parse_orjson(raw_data) or self._parse_json(raw_data)
|
59
|
+
|
60
|
+
if body_json is None:
|
60
61
|
raise AirbyteTracedException(
|
61
|
-
message="JSON data failed to be parsed. See logs for more
|
62
|
-
internal_message=f"JSON data
|
62
|
+
message="Response JSON data failed to be parsed. See logs for more information.",
|
63
|
+
internal_message=f"Response JSON data failed to be parsed.",
|
63
64
|
failure_type=FailureType.system_error,
|
64
|
-
exception=exc,
|
65
65
|
)
|
66
66
|
|
67
|
-
if
|
68
|
-
body_json = [body_json]
|
69
|
-
if len(body_json) == 0:
|
70
|
-
yield {}
|
71
|
-
else:
|
67
|
+
if isinstance(body_json, list):
|
72
68
|
yield from body_json
|
69
|
+
else:
|
70
|
+
yield from [body_json]
|
71
|
+
|
72
|
+
def _parse_orjson(self, raw_data: bytes) -> Optional[Any]:
|
73
|
+
try:
|
74
|
+
return orjson.loads(raw_data.decode(self.encoding))
|
75
|
+
except Exception as exc:
|
76
|
+
logger.warning(
|
77
|
+
f"Failed to parse JSON data using orjson library. Falling back to json library. {exc=}"
|
78
|
+
)
|
79
|
+
return None
|
80
|
+
|
81
|
+
def _parse_json(self, raw_data: bytes) -> Optional[Any]:
|
82
|
+
try:
|
83
|
+
return json.loads(raw_data.decode(self.encoding))
|
84
|
+
except Exception as exc:
|
85
|
+
logger.error(f"Failed to parse JSON data using json library. {exc=}")
|
86
|
+
return None
|
73
87
|
|
74
88
|
|
75
89
|
@dataclass
|
@@ -805,14 +805,6 @@ class GzipJsonDecoder(BaseModel):
|
|
805
805
|
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
|
806
806
|
|
807
807
|
|
808
|
-
class JsonParser(BaseModel):
|
809
|
-
class Config:
|
810
|
-
extra = Extra.allow
|
811
|
-
|
812
|
-
type: Literal["JsonParser"]
|
813
|
-
encoding: Optional[str] = "utf-8"
|
814
|
-
|
815
|
-
|
816
808
|
class MinMaxDatetime(BaseModel):
|
817
809
|
type: Literal["MinMaxDatetime"]
|
818
810
|
datetime: str = Field(
|
@@ -1181,6 +1173,14 @@ class LegacySessionTokenAuthenticator(BaseModel):
|
|
1181
1173
|
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
|
1182
1174
|
|
1183
1175
|
|
1176
|
+
class JsonParser(BaseModel):
|
1177
|
+
class Config:
|
1178
|
+
extra = Extra.allow
|
1179
|
+
|
1180
|
+
type: Literal["JsonParser"]
|
1181
|
+
encoding: Optional[str] = "utf-8"
|
1182
|
+
|
1183
|
+
|
1184
1184
|
class JsonLineParser(BaseModel):
|
1185
1185
|
type: Literal["JsonLineParser"]
|
1186
1186
|
encoding: Optional[str] = "utf-8"
|
@@ -1579,7 +1579,7 @@ class RecordSelector(BaseModel):
|
|
1579
1579
|
|
1580
1580
|
class GzipParser(BaseModel):
|
1581
1581
|
type: Literal["GzipParser"]
|
1582
|
-
inner_parser: Union[JsonLineParser, CsvParser]
|
1582
|
+
inner_parser: Union[JsonLineParser, CsvParser, JsonParser]
|
1583
1583
|
|
1584
1584
|
|
1585
1585
|
class Spec(BaseModel):
|
@@ -1614,7 +1614,7 @@ class CompositeErrorHandler(BaseModel):
|
|
1614
1614
|
|
1615
1615
|
class CompositeRawDecoder(BaseModel):
|
1616
1616
|
type: Literal["CompositeRawDecoder"]
|
1617
|
-
parser: Union[GzipParser, JsonLineParser, CsvParser]
|
1617
|
+
parser: Union[GzipParser, JsonParser, JsonLineParser, CsvParser]
|
1618
1618
|
|
1619
1619
|
|
1620
1620
|
class DeclarativeSource1(BaseModel):
|
@@ -66,11 +66,11 @@ airbyte_cdk/sources/declarative/concurrent_declarative_source.py,sha256=tSTCSmyM
|
|
66
66
|
airbyte_cdk/sources/declarative/datetime/__init__.py,sha256=l9LG7Qm6e5r_qgqfVKnx3mXYtg1I9MmMjomVIPfU4XA,177
|
67
67
|
airbyte_cdk/sources/declarative/datetime/datetime_parser.py,sha256=SX9JjdesN1edN2WVUVMzU_ptqp2QB1OnsnjZ4mwcX7w,2579
|
68
68
|
airbyte_cdk/sources/declarative/datetime/min_max_datetime.py,sha256=0BHBtDNQZfvwM45-tY5pNlTcKAFSGGNxemoi0Jic-0E,5785
|
69
|
-
airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=
|
69
|
+
airbyte_cdk/sources/declarative/declarative_component_schema.yaml,sha256=fCvq1sFwE4h7sP9sjZHoggsw8K3pvOEMvnf_es3fizA,133625
|
70
70
|
airbyte_cdk/sources/declarative/declarative_source.py,sha256=nF7wBqFd3AQmEKAm4CnIo29CJoQL562cJGSCeL8U8bA,1531
|
71
71
|
airbyte_cdk/sources/declarative/declarative_stream.py,sha256=JRyNeOIpsFu4ztVZsN6sncqUEIqIE-bUkD2TPgbMgk0,10375
|
72
72
|
airbyte_cdk/sources/declarative/decoders/__init__.py,sha256=edGj4fGxznBk4xzRQyCA1rGfbpqe7z-RE0K3kQQWbgA,858
|
73
|
-
airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py,sha256=
|
73
|
+
airbyte_cdk/sources/declarative/decoders/composite_raw_decoder.py,sha256=VpKcCbRDHhU7yRvwCmc5yQO1KSSUYEOocngDLin6o2s,4359
|
74
74
|
airbyte_cdk/sources/declarative/decoders/decoder.py,sha256=sl-Gt8lXi7yD2Q-sD8je5QS2PbgrgsYjxRLWsay7DMc,826
|
75
75
|
airbyte_cdk/sources/declarative/decoders/json_decoder.py,sha256=qdbjeR6RffKaah_iWvMsOcDolYuxJY5DaI3b9AMTZXg,3327
|
76
76
|
airbyte_cdk/sources/declarative/decoders/noop_decoder.py,sha256=iZh0yKY_JzgBnJWiubEusf5c0o6Khd-8EWFWT-8EgFo,542
|
@@ -106,7 +106,7 @@ airbyte_cdk/sources/declarative/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW
|
|
106
106
|
airbyte_cdk/sources/declarative/migrations/legacy_to_per_partition_state_migration.py,sha256=iemy3fKLczcU0-Aor7tx5jcT6DRedKMqyK7kCOp01hg,3924
|
107
107
|
airbyte_cdk/sources/declarative/migrations/state_migration.py,sha256=KWPjealMLKSMtajXgkdGgKg7EmTLR-CqqD7UIh0-eDU,794
|
108
108
|
airbyte_cdk/sources/declarative/models/__init__.py,sha256=nUFxNCiKeYRVXuZEKA7GD-lTHxsiKcQ8FitZjKhPIvE,100
|
109
|
-
airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=
|
109
|
+
airbyte_cdk/sources/declarative/models/declarative_component_schema.py,sha256=_aQM6pF-a4Zk7kQ-_GiVaRi30bpyTQDg4G7KZD83yuI,93560
|
110
110
|
airbyte_cdk/sources/declarative/parsers/__init__.py,sha256=ZnqYNxHsKCgO38IwB34RQyRMXTs4GTvlRi3ImKnIioo,61
|
111
111
|
airbyte_cdk/sources/declarative/parsers/custom_exceptions.py,sha256=Rir9_z3Kcd5Es0-LChrzk-0qubAsiK_RSEnLmK2OXm8,553
|
112
112
|
airbyte_cdk/sources/declarative/parsers/manifest_component_transformer.py,sha256=CXwTfD3wSQq3okcqwigpprbHhSURUokh4GK2OmOyKC8,9132
|
@@ -342,8 +342,8 @@ airbyte_cdk/utils/slice_hasher.py,sha256=-pHexlNYoWYPnXNH-M7HEbjmeJe9Zk7SJijdQ7d
|
|
342
342
|
airbyte_cdk/utils/spec_schema_transformations.py,sha256=-5HTuNsnDBAhj-oLeQXwpTGA0HdcjFOf2zTEMUTTg_Y,816
|
343
343
|
airbyte_cdk/utils/stream_status_utils.py,sha256=ZmBoiy5HVbUEHAMrUONxZvxnvfV9CesmQJLDTAIWnWw,1171
|
344
344
|
airbyte_cdk/utils/traced_exception.py,sha256=C8uIBuCL_E4WnBAOPSxBicD06JAldoN9fGsQDp463OY,6292
|
345
|
-
airbyte_cdk-6.18.0.
|
346
|
-
airbyte_cdk-6.18.0.
|
347
|
-
airbyte_cdk-6.18.0.
|
348
|
-
airbyte_cdk-6.18.0.
|
349
|
-
airbyte_cdk-6.18.0.
|
345
|
+
airbyte_cdk-6.18.0.dev2.dist-info/LICENSE.txt,sha256=Wfe61S4BaGPj404v8lrAbvhjYR68SHlkzeYrg3_bbuM,1051
|
346
|
+
airbyte_cdk-6.18.0.dev2.dist-info/METADATA,sha256=0EfivelRXCgquhtK-6kt045d65qTAYxlGhu5j2Vg_FY,6005
|
347
|
+
airbyte_cdk-6.18.0.dev2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
348
|
+
airbyte_cdk-6.18.0.dev2.dist-info/entry_points.txt,sha256=fj-e3PAQvsxsQzyyq8UkG1k8spunWnD4BAH2AwlR6NM,95
|
349
|
+
airbyte_cdk-6.18.0.dev2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|