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

fix(ingestion): properly detect optional fields in avro schemas #2343

Merged
merged 3 commits into from
Apr 8, 2021
Merged

fix(ingestion): properly detect optional fields in avro schemas #2343

merged 3 commits into from
Apr 8, 2021

Conversation

thomasplarsson
Copy link
Contributor

@thomasplarsson thomasplarsson commented Apr 6, 2021

Fixes: #2342

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable)

@@ -71,7 +71,7 @@ def avro_schema_to_mce_fields(avro_schema_string: str) -> List[SchemaField]:
type=_get_column_type(parsed_field.type),
description=parsed_field.props.get("doc", None),
recursive=False,
nullable=(parsed_field.type == "null"),
nullable=parsed_field.has_default,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fields can also be null if they are of type [ "null", "something else" ] as discussed here. This change will miss those cases, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

For full correctness, the nullable logic might need to be a bit more complex: union types should inherit their default values and nullability from the first type in the union.

This might be ok to do in a follow-up PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, my avro knowledge is far from good. I updated the PR to a solution that more closely resembles the existing behaviour. Please let me know what you think.

Copy link
Collaborator

@hsheth2 hsheth2 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@jjoyce0510 jjoyce0510 left a comment

Choose a reason for hiding this comment

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

Looks great to me - Thanks Thomas!

@shirshanka Can we get this merged in?

Copy link
Contributor

@shirshanka shirshanka left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @thomasplarsson

@shirshanka shirshanka merged commit 4215dcd into datahub-project:master Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kafka ingestion handles nullable fields incorrectly
4 participants