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

[Python schema] Support python avro schema set default value. #10265

Conversation

congbobo184
Copy link
Contributor

Motivation

now python avro schema don't support set default value, it led to the python schema can't update.

implement

  1. add required field to control the type of schema can set null.
  2. add required_default filed to control to control the schema has default attribute wether or not.
  3. add default field to control the default value of schema.

Verifying this change

Add the tests for it

Does this pull request potentially affect one of the following parts:
If yes was chosen, please highlight the changes

Dependencies (does it add or upgrade a dependency): (no)
The public API: (no)
The schema: (no)
The default values of configurations: (no)
The wire protocol: (no)
The rest endpoints: (no)
The admin cli options: (no)
Anything that affects deployment: (no)

@congbobo184
Copy link
Contributor Author

@BewareMyPower could you please review this pr? thanks :)

@BewareMyPower
Copy link
Contributor

It looks like there're still some problems with the implementation.

File "/tmp/schema_test.py", line 810, in test_avro_required_default
    "default": None
AssertionError: {'fields': [{'default': None, 'type': ['null', 'int'], 'name': 'a'}, {'default': [truncated]... != {'fields': [{'default': None, 'type': ['null', 'int'], 'name': 'a'}, {'default': [truncated]...

@codelipenghui
Copy link
Contributor

mark as release/2.7.2 since this is a bug when the users using the schema in the Python client.

@codelipenghui codelipenghui merged commit d6d0e3a into apache:master Apr 19, 2021
congbobo184 added a commit that referenced this pull request Apr 29, 2021
## Motivation
now python avro schema don't support set default value, it led to the python schema can't update.
## implement
1. add `required` field to control the type of schema can set `null`.
2. add `required_default` filed to control to control the schema has default attribute wether or not.
3. add `default` field to control the default value of schema.

(cherry picked from commit d6d0e3a)
@congbobo184 congbobo184 added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.7 Archived: 2.7 is end of life release/2.7.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants