1
0
mirror of synced 2026-01-21 06:08:50 -05:00
Files
airbyte/airbyte-integrations/connectors/source-iterable/source_iterable/components.py
Artem Inzhyyants bc0b9b9d4a fix(source-iterable): fix OOM errors (#41983)
Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
2024-07-22 12:31:09 +02:00

23 lines
805 B
Python

#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from dataclasses import dataclass
from typing import Any, Iterable, Mapping
import requests
from airbyte_cdk.sources.declarative.extractors.dpath_extractor import DpathExtractor
@dataclass
class EventsRecordExtractor(DpathExtractor):
common_fields = ("itblInternal", "_type", "createdAt", "email")
def extract_records(self, response: requests.Response) -> Iterable[Mapping[str, Any]]:
jsonl_records = super().extract_records(response=response)
for record_dict in jsonl_records:
record_dict_common_fields = {}
for field in self.common_fields:
record_dict_common_fields[field] = record_dict.pop(field, None)
yield {**record_dict_common_fields, "data": record_dict}