-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Python Schema] Fix redefined Record
or Enum
in Python schema
#11595
[Python Schema] Fix redefined Record
or Enum
in Python schema
#11595
Conversation
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.
Block this PR to wait until #11557 is merged.
Thanks for your contribution. For this PR, do we need to update docs? (The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks) |
Could you rebase to master to make sure CI passed? |
I added the |
@BewareMyPower thanks! |
2866080
to
9487b70
Compare
…#11595) Fixes apache#11533 ### Motivation Refer to issue apache#11533 , currently, if users redefined the same `Record` or `Enum` in `Record`, the schema info isn't reused the defined name, this does not match the Avro schema info format. ### Modifications Add a new method `schema_info(self, defined_names)` in `Record`, `Array`, `Map`, and `Enum`, all defined names will be added in the parameter `defined_names` when users use a defined `Record`, or `Enum`, the schema info will use the name of the defined `Record` or `Enum` as the type.
@@ -393,6 +413,9 @@ def python_type(self): | |||
return list | |||
|
|||
def validate_type(self, name, val): | |||
if val is None: | |||
return None |
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.
Should return the self.default()
, not None
automatically
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.
Good catch, I'll fix this. Thanks
Fixes #11533 ### Motivation Refer to issue #11533 , currently, if users redefined the same `Record` or `Enum` in `Record`, the schema info isn't reused the defined name, this does not match the Avro schema info format. ### Modifications Add a new method `schema_info(self, defined_names)` in `Record`, `Array`, `Map`, and `Enum`, all defined names will be added in the parameter `defined_names` when users use a defined `Record`, or `Enum`, the schema info will use the name of the defined `Record` or `Enum` as the type. (cherry picked from commit d66cdbd)
…#11595) Fixes apache#11533 ### Motivation Refer to issue apache#11533 , currently, if users redefined the same `Record` or `Enum` in `Record`, the schema info isn't reused the defined name, this does not match the Avro schema info format. ### Modifications Add a new method `schema_info(self, defined_names)` in `Record`, `Array`, `Map`, and `Enum`, all defined names will be added in the parameter `defined_names` when users use a defined `Record`, or `Enum`, the schema info will use the name of the defined `Record` or `Enum` as the type.
Fixes #11533
Motivation
Refer to issue #11533 , currently, if users redefined the same
Record
orEnum
inRecord
, the schema info isn't reused the defined name, this does not match the Avro schema info format.Modifications
Add a new method
schema_info(self, defined_names)
inRecord
,Array
,Map
, andEnum
, all defined names will be added in the parameterdefined_names
when users use a definedRecord
, orEnum
, the schema info will use the name of the definedRecord
orEnum
as the type.Verifying this change
Add test to verify using same
Record
orEnum
in a complexRecord
.Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation
For committer
For this PR, do we need to update docs?
If yes,
if you update docs in this PR, label this PR with the
doc
label.if you plan to update docs later, label this PR with the
doc-required
label.if you need help on updating docs, create a follow-up issue with the
doc-required
label.If no, label this PR with the
no-need-doc
label and explain why.