Repository navigation
feat(low-code): add regex and copy options to KeysReplace - #1213
Draft
devin-ai-integration[bot] wants to merge 1 commit into
Draft
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…ath options to KeysReplace Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1791298896-keys-replace-regex-copy-options#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1791298896-keys-replace-regex-copy-optionsPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds four optional fields to the declarative
KeysReplacetransformation so low-code connectors can drop custom key-mapping components (e.g. source-hubspot'sNewtoLegacyFieldTransformation). All defaults reproduce today's behavior (literal match, recursive, rename), so existing manifests are unaffected.Resolves https://github.com/airbytehq/airbyte-internal-issues/issues/17742:
Close on merge: yes — internally filed, no customer to confirm with.
Part of epic https://github.com/airbytehq/airbyte-internal-issues/issues/17701. Requested via
/ai-fixon the issue above (issue author: Anatolii Yatsuk (@tolik0)). The HubSpot migration is a separate sub-issue and is not part of this PR.regexfalseoldis a regex,neware.subreplacement (\1,\g<1>,\g<name>). Invalid pattern / group reference raisesValueErrorwhen the component is created (or at first transform ifold/neware interpolated).keep_originalfalseonly_if_missingfalsenull. In rename mode the original key is left as-is when it is not written.field_pathDpathFlattenFields.field_path(config-interpolated,*wildcard). Missing path / non-object → no-op.Example (equivalent to the HubSpot contacts mapping, including "don't double-append
_date"):Semantics / implementation notes
field_pathtarget. Withkeep_original, nested objects are transformed first, then copied.a -> aawithkeep_originalyields{a, aa}, notaaa).old/neware used verbatim in regex mode:JinjaInterpolationrunsast.literal_evalon rendered output, which would turn a pattern like(1)into1. Interpolated values are evaluated withvalid_types=(str,).declarative_component_schema.yaml, so the new descriptions and HubSpot-derived examples live there.poe assemble; unrelated generator churn was reverted so only theKeysReplacefields are in the diff.Reproduction
New tests run against unmodified
maincode (implementation stashed):28 failed, 15 passed— the new options are silently ignored by the model and the transformation always does a literal rename (e.g.hs_v2_date_entered_poetryis lost on collision withhs_date_entered_poetry).Declarative-First Evaluation
Not a connector change: this PR extends a built-in declarative component in the CDK itself so that connectors can replace a custom Python component with manifest-only config. No custom connector component is added. Existing alternatives (
AddFieldswith dynamic keys,KeysToLower/KeysToSnakeCase,DpathFlattenFields) can't do regex-based key copy with "only if missing" semantics on a sub-object or a dynamic schema map.Test Coverage
unit_tests/sources/declarative/transformations/test_keys_replace_transformation.py: defaults (literal/recursive/rename/collision), regex\1/\g<1>/\g<name>, backslashes in pattern, plain regex not literal-evaluated, interpolated regex,keep_original(incl. no duplication of unmatched keys, no aliasing),only_if_missingabsent/null/present in both modes and key orders,field_pathscoping/interpolation/wildcard/missing/non-dict, snapshot semantics, invalid regex at construction and at transform.unit_tests/sources/declarative/parsers/test_model_to_component_factory.py: defaults, all options parsed from YAML (backreference survives YAML parsing), invalid regex raises at creation.unit_tests/sources/declarative/schema/test_dynamic_schema_loader.py: end-to-enddiscoverwithKeysReplaceinschema_transformations.poetry run pytest unit_tests/sources/declarative: 2375 passed; 1 failure intest_jwt.py::test_get_request_options, a timing flake (iatoff by 1s) that passes on rerun and is unrelated.NewtoLegacyFieldTransformation(deals and contacts mappings) on 12,000 randomized records/schemas: identical output.ruff check,ruff format --check,mypyon changed sources: clean.Breaking change evaluation
Non-breaking: all new fields are optional with defaults that preserve current behavior; no existing fields changed or removed. CDK version is set at release time (
feat:→ minor).Link to Devin session: https://app.devin.ai/sessions/bf3541d200a04648bbe2115190d3c03f
Open in Devin Desktop: https://app.devin.ai/desktop/session/bf3541d200a04648bbe2115190d3c03f?variant=devin