-
Notifications
You must be signed in to change notification settings - Fork 45
feat: add CustomSchemaNormalization
#194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Artem Inzhyyants (artem1205)
merged 14 commits into
main
from
artem1205/add-custom-type-transformer
Jan 9, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3984559
CDK: add custom type transformer
artem1205 2433340
CDK: ref
artem1205 9bdfb73
CDK: fix
artem1205 c9202e5
CDK: fix typo
artem1205 26b99bf
CDK: fix schema
artem1205 8db550a
CDK: reorder definition declaration
artem1205 4f64a45
CDK: ref
artem1205 e7a6c0c
CDK: fix tests
artem1205 f787b6d
CDK: add AbstractTypeTransformer
artem1205 0a37dd0
Merge branch 'main' into artem1205/add-custom-type-transformer
artem1205 eeba5cc
CDK: ref
artem1205 e82682a
CDK: rename
artem1205 f9d2212
CDK: ref
artem1205 049370d
Merge branch 'main' into artem1205/add-custom-type-transformer
artem1205 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.