-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
@@ -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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
metadata-ingestion/src/datahub/ingestion/extractor/schema_util.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @thomasplarsson
Fixes: #2342
Checklist