You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "aiven-anton (via GitHub)" <gi...@apache.org> on 2023/05/24 15:28:26 UTC
[GitHub] [avro] aiven-anton opened a new pull request, #2250: AVRO-3760: Fix resolution of future enum with default symbol
aiven-anton opened a new pull request, #2250:
URL: https://github.com/apache/avro/pull/2250
<!--
*Thank you very much for contributing to Apache Avro - we are happy that you want to help us improve Avro. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Avro a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/AVRO/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "AVRO-XXXX: [component] Title of the pull request", where *AVRO-XXXX* should be replaced by the actual issue number.
The *component* is optional, but can help identify the correct reviewers faster: either the language ("java", "python") or subsystem such as "build" or "doc" are good candidates.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests. You can [build the entire project](https://github.com/apache/avro/blob/master/BUILD.md) or just the [language-specific SDK](https://avro.apache.org/project/how-to-contribute/#unit-tests).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Every commit message references Jira issues in their subject lines. In addition, commits follow the guidelines from [How to write a good git commit message](https://chris.beams.io/posts/git-commit/)
1. Subject is separated from body by a blank line
1. Subject is limited to 50 characters (not including Jira issue reference)
1. Subject does not end with a period
1. Subject uses the imperative mood ("add", not "adding")
1. Body wraps at 72 characters
1. Body explains "what" and "why", not "how"
-->
## What is the purpose of the change
Parsing an enum should resolve to the default symbol when the symbol is not known to the reader. This raised a SchemaResolutionError. The patch adds handling of default symbols, see AVRO-3760.
## Verifying this change
The change adds tests that verifies that the behavior is now in line with the spec, but retains the current behavior when there is no default symbol.
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [avro] RyanSkraba commented on a diff in pull request #2250: AVRO-3760: [python] Fix resolution of future enum with default symbol
Posted by "RyanSkraba (via GitHub)" <gi...@apache.org>.
RyanSkraba commented on code in PR #2250:
URL: https://github.com/apache/avro/pull/2250#discussion_r1231338739
##########
lang/py/avro/io.py:
##########
@@ -776,6 +766,9 @@ def read_enum(self, writers_schema: avro.schema.EnumSchema, readers_schema: avro
# read data
index_of_symbol = decoder.read_int()
if index_of_symbol >= len(writers_schema.symbols):
+ default = writers_schema.default
Review Comment:
From my comment on AVRO-3760 -- if we're a bit more strict, this should probably fail here when there's not a readers_schema. We should discuss on the JIRA what we actually want to do.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3760: [python] Fix resolution of future enum with default symbol [avro]
Posted by "RyanSkraba (via GitHub)" <gi...@apache.org>.
RyanSkraba merged PR #2250:
URL: https://github.com/apache/avro/pull/2250
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [avro] aiven-anton commented on a diff in pull request #2250: AVRO-3760: [python] Fix resolution of future enum with default symbol
Posted by "aiven-anton (via GitHub)" <gi...@apache.org>.
aiven-anton commented on code in PR #2250:
URL: https://github.com/apache/avro/pull/2250#discussion_r1204712785
##########
lang/py/avro/io.py:
##########
@@ -89,17 +89,7 @@
import decimal
import struct
import warnings
-from typing import (
- IO,
- Deque,
- Generator,
- Iterable,
- List,
- Mapping,
- Optional,
- Sequence,
- Union,
-)
+from typing import IO, Generator, Iterable, List, Mapping, Optional, Sequence, Union
Review Comment:
The `Deque` import was unused.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [avro] kojiromike commented on a diff in pull request #2250: AVRO-3760: [python] Fix resolution of future enum with default symbol
Posted by "kojiromike (via GitHub)" <gi...@apache.org>.
kojiromike commented on code in PR #2250:
URL: https://github.com/apache/avro/pull/2250#discussion_r1260487295
##########
lang/py/avro/schema.py:
##########
@@ -587,6 +587,15 @@ def symbols(self) -> Sequence[str]:
return symbols
raise Exception
+ @property
+ def default(self) -> Union[str, None]:
+ symbol = self.get_prop("default")
+ if isinstance(symbol, str):
+ return symbol
+ if symbol is None:
+ return None
+ raise Exception
Review Comment:
Please consider raising a more specific exception in this case. Would [avro.errors.InvalidDefault](https://github.com/apache/avro/blob/895c3db01860c44eef9f21de642b63049550366b/lang/py/avro/errors.py#L47) make sense?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org