-
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] Python schema support custom Avro configurations for Enum type #12642
Merged
codelipenghui
merged 3 commits into
apache:master
from
gaoran10:gaoran/python-schema-support-custom-enum
Nov 7, 2021
Merged
[Python Schema] Python schema support custom Avro configurations for Enum type #12642
codelipenghui
merged 3 commits into
apache:master
from
gaoran10:gaoran/python-schema-support-custom-enum
Nov 7, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ields for Enum type in Record.
@gaoran10:Thanks for your contribution. For this PR, do we need to update docs? |
codelipenghui
approved these changes
Nov 5, 2021
tuteng
approved these changes
Nov 5, 2021
merlimat
approved these changes
Nov 5, 2021
codelipenghui
pushed a commit
that referenced
this pull request
Nov 7, 2021
…Enum type (#12642) ### Motivation Currently, the Python client didn't support setting configurations `required`, `default`, `required_default` for Enum type in Record. ### Modifications Modify the `_Enum` class to `CustomEnum` class, the `_Enum` wasn't exposed to users, the new class `CustomEnum` will be exposed to users, they could set Avro definition configurations `required`, `default`, `required_default`. ### How to use ``` class Color(Enum): red = 1 green = 2 blue = 3 class NestedObj(Record): a = Integer() color = CustomEnum(Color, required_default=True, default=Color.blue) ``` The schema definition will be like this ``` { 'type': 'record', 'name': 'NestedObj', 'fields': [ {'name': 'a', 'type': ['null', 'int']}, {'name': 'color', 'default': 'blue', 'type': ['null', {'type': 'enum', 'name': 'Color', 'symbols': ['red', 'green', 'blue']}]} ] } ``` The old way of use will also be preserved. This feature could work well with Java client. (cherry picked from commit e7389ed)
zeo1995
pushed a commit
to zeo1995/pulsar
that referenced
this pull request
Nov 7, 2021
* up/master: (55 commits) [broker] remove useless method "PersistentTopic#getPersistentTopic" (apache#12655) [Python Schema] Python schema support custom Avro configurations for Enum type (apache#12642) Allow to configure different implementations for Pulsar functions state store (apache#12646) Remove replicator global test from the quarantine group (apache#12648) [Java Client] Remove invalid call to Thread.currentThread().interrupt(); (apache#12652) k8s runtime: force deletion to avoid hung function worker during connector restart (apache#12504) [Broker] Optimize exception information for schemas (apache#12647) Close Zk database on unit tests (apache#12649) Fix call sync method in an async callback when enabling geo replicator. (apache#12590) [pulsar-broker] Add git branch information for PulsarVersion (apache#12541) PulsarAdmin: Fix last exit code storage (apache#12581) Add @test annotation to test methods (apache#12640) Upgrade debezium to 1.7.1 (apache#12644) [ML] Avoid passing OpAddEntry across a thread boundary in asyncAddEntry (apache#12606) [Functions] Prevent NPE while stopping a non started Pulsar LogAppender (apache#12643) Update io-debezium-source.md (apache#12638) Add missing cmds on pulsar-admin document page (apache#12634) Clean up the metadata of the non-persistent partitioned topics. (apache#12550) modify check waitingForPingResponse with volatile (apache#12615) [pulsar-admin] Check backlog quota policy for namespace (apache#12512) ...
zeo1995
pushed a commit
to zeo1995/pulsar
that referenced
this pull request
Nov 7, 2021
* up/master: (55 commits) [broker] remove useless method "PersistentTopic#getPersistentTopic" (apache#12655) [Python Schema] Python schema support custom Avro configurations for Enum type (apache#12642) Allow to configure different implementations for Pulsar functions state store (apache#12646) Remove replicator global test from the quarantine group (apache#12648) [Java Client] Remove invalid call to Thread.currentThread().interrupt(); (apache#12652) k8s runtime: force deletion to avoid hung function worker during connector restart (apache#12504) [Broker] Optimize exception information for schemas (apache#12647) Close Zk database on unit tests (apache#12649) Fix call sync method in an async callback when enabling geo replicator. (apache#12590) [pulsar-broker] Add git branch information for PulsarVersion (apache#12541) PulsarAdmin: Fix last exit code storage (apache#12581) Add @test annotation to test methods (apache#12640) Upgrade debezium to 1.7.1 (apache#12644) [ML] Avoid passing OpAddEntry across a thread boundary in asyncAddEntry (apache#12606) [Functions] Prevent NPE while stopping a non started Pulsar LogAppender (apache#12643) Update io-debezium-source.md (apache#12638) Add missing cmds on pulsar-admin document page (apache#12634) Clean up the metadata of the non-persistent partitioned topics. (apache#12550) modify check waitingForPingResponse with volatile (apache#12615) [pulsar-admin] Check backlog quota policy for namespace (apache#12512) ...
eolivelli
pushed a commit
to eolivelli/pulsar
that referenced
this pull request
Nov 29, 2021
…Enum type (apache#12642) ### Motivation Currently, the Python client didn't support setting configurations `required`, `default`, `required_default` for Enum type in Record. ### Modifications Modify the `_Enum` class to `CustomEnum` class, the `_Enum` wasn't exposed to users, the new class `CustomEnum` will be exposed to users, they could set Avro definition configurations `required`, `default`, `required_default`. ### How to use ``` class Color(Enum): red = 1 green = 2 blue = 3 class NestedObj(Record): a = Integer() color = CustomEnum(Color, required_default=True, default=Color.blue) ``` The schema definition will be like this ``` { 'type': 'record', 'name': 'NestedObj', 'fields': [ {'name': 'a', 'type': ['null', 'int']}, {'name': 'color', 'default': 'blue', 'type': ['null', {'type': 'enum', 'name': 'Color', 'symbols': ['red', 'green', 'blue']}]} ] } ``` The old way of use will also be preserved. This feature could work well with Java client.
codelipenghui
pushed a commit
that referenced
this pull request
Dec 20, 2021
…Enum type (#12642) ### Motivation Currently, the Python client didn't support setting configurations `required`, `default`, `required_default` for Enum type in Record. ### Modifications Modify the `_Enum` class to `CustomEnum` class, the `_Enum` wasn't exposed to users, the new class `CustomEnum` will be exposed to users, they could set Avro definition configurations `required`, `default`, `required_default`. ### How to use ``` class Color(Enum): red = 1 green = 2 blue = 3 class NestedObj(Record): a = Integer() color = CustomEnum(Color, required_default=True, default=Color.blue) ``` The schema definition will be like this ``` { 'type': 'record', 'name': 'NestedObj', 'fields': [ {'name': 'a', 'type': ['null', 'int']}, {'name': 'color', 'default': 'blue', 'type': ['null', {'type': 'enum', 'name': 'Color', 'symbols': ['red', 'green', 'blue']}]} ] } ``` The old way of use will also be preserved. This feature could work well with Java client. (cherry picked from commit e7389ed)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cherry-picked/branch-2.8
Archived: 2.8 is end of life
cherry-picked/branch-2.9
Archived: 2.9 is end of life
doc-not-needed
Your PR changes do not impact docs
release/2.8.2
release/2.9.2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, the Python client didn't support setting configurations
required
,default
,required_default
for Enum type in Record.Modifications
Modify the
_Enum
class toCustomEnum
class, the_Enum
wasn't exposed to users, the new classCustomEnum
will be exposed to users, they could set Avro definition configurationsrequired
,default
,required_default
.How to use
The schema definition will be like this
The old way of use will also be preserved.
This feature could work well with Java client.
Verifying this change
Make some changes in existing tests to verify this new feature.
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation
Check the box below and label this PR (if you have committer privilege).
Need to update docs?
doc-required
(If you need help on updating docs, create a doc issue)
no-need-doc
(Please explain why)
doc
(If this PR contains doc changes)