Skip to content
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

File-based CDK: fix schemas merge for nullable object types #37619

Merged
merged 3 commits into from
May 2, 2024

Conversation

askarpets
Copy link
Contributor

@askarpets askarpets commented Apr 26, 2024

What

Fix for https://github.com/airbytehq/oncall/issues/4948

How

Skip choosing wider type if a key is present in schema1 and schema2, but has a type of null in schema2

Review guide

  1. schema_helpers.py
  2. test_schema_helpers.py

User Impact

No

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

@askarpets askarpets self-assigned this Apr 26, 2024
@askarpets askarpets requested a review from a team April 26, 2024 10:56
Copy link

vercel bot commented Apr 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 11:21am

@octavia-squidington-iii octavia-squidington-iii added the CDK Connector Development Kit label Apr 26, 2024
@askarpets askarpets requested review from bazarnov and lazebnyi April 26, 2024 11:29
@natikgadzhi
Copy link
Contributor

To clarify, would it just make that if the second schema has a field and it's type is null, that null type won't be added to the existing schema's type?

Why would second schema's field type be null only?

@askarpets
Copy link
Contributor Author

To clarify, would it just make that if the second schema has a field and it's type is null, that null type won't be added to the existing schema's type?

@natikgadzhi that field with null type will be added if it's not in the schema yet

Why would second schema's field type be null only?

This is what I found during investigation of https://github.com/airbytehq/oncall/issues/4948

@askarpets askarpets requested a review from clnoll April 30, 2024 08:43
Copy link
Contributor

@clnoll clnoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roman-yermilov-gl the code change looks good, but can you explain how this solves the problem in the ticket? I think a code comment with this info would be helpful too.

@askarpets
Copy link
Contributor Author

@roman-yermilov-gl the code change looks good, but can you explain how this solves the problem in the ticket? I think a code comment with this info would be helpful too.

@clnoll the user is facing an issue when running the discover command. I found that some of their files have records like below:

record 1: {"a": {"some_key": "some_value"}}
record 2: {"a": null}

Because of that, the schema could not be merged due to this logic, so I decided to not pass fields with null values to the _choose_wider_type method if their keys are already in the merged schema. Does that make sense?

Copy link
Contributor

@clnoll clnoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@askarpets, sorry I tagged Roman instead of you!

Thanks for the explanation, it makes sense to me. Can you please add a comment to the code about this bug?

@askarpets
Copy link
Contributor Author

Added, thanks for the review @clnoll!

@askarpets askarpets merged commit 2cfa6ea into master May 2, 2024
33 checks passed
@askarpets askarpets deleted the file-based-cdk-fix-merge-schemas branch May 2, 2024 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants