[Python Schema] Fix redefined Record or Enum in Python schema#11595
Conversation
BewareMyPower
left a comment
There was a problem hiding this comment.
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.
|
|
||
| def validate_type(self, name, val): | ||
| if val is None: | ||
| return None |
There was a problem hiding this comment.
Should return the self.default(), not None automatically
There was a problem hiding this comment.
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
RecordorEnuminRecord, 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_nameswhen users use a definedRecord, orEnum, the schema info will use the name of the definedRecordorEnumas the type.Verifying this change
Add test to verify using same
RecordorEnumin a complexRecord.Does this pull request potentially affect one of the following parts:
If
yeswas 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
doclabel.if you plan to update docs later, label this PR with the
doc-requiredlabel.if you need help on updating docs, create a follow-up issue with the
doc-requiredlabel.If no, label this PR with the
no-need-doclabel and explain why.