-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
CustomSchemaNormalization
(#194)
Signed-off-by: Artem Inzhyyants <[email protected]>
- Loading branch information
Showing
6 changed files
with
129 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
airbyte_cdk/sources/declarative/extractors/type_transformer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# | ||
# Copyright (c) 2025 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
from abc import ABC, abstractmethod | ||
from dataclasses import dataclass | ||
from typing import Any, Dict, Mapping | ||
|
||
|
||
@dataclass | ||
class TypeTransformer(ABC): | ||
""" | ||
Abstract base class for implementing type transformation logic. | ||
This class provides a blueprint for defining custom transformations | ||
on data records based on a provided schema. Implementing classes | ||
must override the `transform` method to specify the transformation | ||
logic. | ||
Attributes: | ||
None explicitly defined, as this is a dataclass intended to be | ||
subclassed. | ||
Methods: | ||
transform(record: Dict[str, Any], schema: Mapping[str, Any]) -> None: | ||
Abstract method that must be implemented by subclasses. | ||
It performs a transformation on a given data record based | ||
on the provided schema. | ||
Usage: | ||
To use this class, create a subclass that implements the | ||
`transform` method with the desired transformation logic. | ||
""" | ||
|
||
@abstractmethod | ||
def transform( | ||
self, | ||
record: Dict[str, Any], | ||
schema: Mapping[str, Any], | ||
) -> None: | ||
""" | ||
Perform a transformation on a data record based on a given schema. | ||
Args: | ||
record (Dict[str, Any]): The data record to be transformed. | ||
schema (Mapping[str, Any]): The schema that dictates how | ||
the record should be transformed. | ||
Returns: | ||
None | ||
Raises: | ||
NotImplementedError: If the method is not implemented | ||
by a subclass. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters