Repository navigation
Conversation
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
… 'Variant' Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
…ariants Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Rename the test method to be different than the one in serde_enum.rs IT tests. Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
martin-g
reviewed
Nov 11, 2022
| #[derive(Debug, Deserialize, Serialize, PartialEq, Eq)] | ||
| enum TestEnum { | ||
| NullVariant1, | ||
| NullVariant2, |
Member
There was a problem hiding this comment.
Both NullVariant1 and NullVariant2 are serialized to Value::Null.
According to the Avro specification there could be one value of a given type in an union:
Unions may not contain more than one schema with the same type, except for the named types record, fixed and enum.
So, it is not possible to have two null variants, no matter whether they are an unit, a tuple, a newtype, a struct or a mix of them.
martin-g
reviewed
Nov 11, 2022
| NullNewTypeVariant(()), | ||
| NullStructVariant {}, | ||
| IntVariant1(i64), | ||
| IntVariant2(i64), |
Member
There was a problem hiding this comment.
Same problem here - two Value::Long in a Union.
Member
There was a problem hiding this comment.
4f710dd removes the duplicates and fixes the Avro schema for the test. Now it passes!
But I think we should merge serde_enum.rs and serde_enum_with_duplicates.rs and remove one of the files.
A Union could have at most one item for a primitive type Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
Member
|
I'm going to merge this PR and do the cleanup in #1921 |
martin-g
added a commit
that referenced
this pull request
Feb 9, 2023
…ariants (#1949) * AVRO-3646: Add a test that (de)serialize a enum with mixed variants * AVRO-3646: Add a test that (de)serialize a enum w/ duplicates variants * Enable PR checks for all PRs, not just the ones against master Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> * AVRO-3646: Fix a clippy error about enum variant being postfixed with 'Variant' Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> * AVRO-3646: Fix the serialization (X -> types::Value) for enum tuple variants Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> * AVRO-3646: Fix the name of the enum variants in the Avro schema Rename the test method to be different than the one in serde_enum.rs IT tests. Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> * AVRO-3646: Remove the duplicates to conform to Avro specification A Union could have at most one item for a primitive type Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> * AVRO-3646: Remove dbg!() statement. Fix clippy errors Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> Co-authored-by: LucasJavaudin <[email protected]> Co-authored-by: Martin Tzvetanov Grigorov <[email protected]>
martin-g
added a commit
that referenced
this pull request
Feb 9, 2023
…ariants (#1949) * AVRO-3646: Add a test that (de)serialize a enum with mixed variants * AVRO-3646: Add a test that (de)serialize a enum w/ duplicates variants * Enable PR checks for all PRs, not just the ones against master Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> * AVRO-3646: Fix a clippy error about enum variant being postfixed with 'Variant' Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> * AVRO-3646: Fix the serialization (X -> types::Value) for enum tuple variants Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> * AVRO-3646: Fix the name of the enum variants in the Avro schema Rename the test method to be different than the one in serde_enum.rs IT tests. Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> * AVRO-3646: Remove the duplicates to conform to Avro specification A Union could have at most one item for a primitive type Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> * AVRO-3646: Remove dbg!() statement. Fix clippy errors Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> Signed-off-by: Martin Tzvetanov Grigorov <[email protected]> Co-authored-by: LucasJavaudin <[email protected]> Co-authored-by: Martin Tzvetanov Grigorov <[email protected]>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is the purpose of the change
This pull request adds two integration tests to assess the changes of #1921:
serde_enum.serde_enum_with_duplicates.Verifying this change
The two integration tests do not pass for multiple reasons:
typevalue for the tuple variant is serialized as anArrayofUnioninstead as anUnionofArray.typeunion is not valid (because there is no duplicate in the union defined by the schema).Documentation