You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "rayokota (via GitHub)" <gi...@apache.org> on 2024/11/16 02:38:08 UTC
[PR] AVRO 4091: [C#] Allow previously parsed schemas to be referenced when parsing a schema [avro]
rayokota opened a new pull request, #3242:
URL: https://github.com/apache/avro/pull/3242
<!--
*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/main/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
Currently the C# Avro library does not have a way to parse a new schema that refers to named schemas that have been previously parsed.
The equivalent in the Java Avro library is to construct an instance of `Schema.Parser` and to use the same parser instance to parse the referenced schemas before the referring schema.
The change that is needed is to simply change the following method in `Schema.cs` from internal to public:
```
internal static Schema Parse(string json, SchemaNames names, string encspace)
```
Without this change, tools that allow Avro schemas to reference one another, such as the Confluent Schema Registry, cannot interoperate well with C# applications.
## Verifying this change
*(Please pick one of the following options)*
This change is a trivial rework / code cleanup without any test coverage.
*(or)*
This change is already covered by existing tests, such as *(please describe tests)*.
*(or)*
This change added tests and can be verified as follows:
*(example:)*
- *Extended interop tests to verify consistent valid schema names between SDKs*
- *Added test that validates that Java throws an AvroRuntimeException on invalid binary data*
- *Manually verified the change by building the website and checking the new redirect*
## Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
--
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
Re: [PR] AVRO 4091: [C#] Allow previously parsed schemas to be referenced when parsing a schema [avro]
Posted by "zcsizmadia (via GitHub)" <gi...@apache.org>.
zcsizmadia merged PR #3242:
URL: https://github.com/apache/avro/pull/3242
--
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
Re: [PR] AVRO 4091: [C#] Allow previously parsed schemas to be referenced when parsing a schema [avro]
Posted by "rayokota (via GitHub)" <gi...@apache.org>.
rayokota commented on PR #3242:
URL: https://github.com/apache/avro/pull/3242#issuecomment-2485025556
Thanks for the review @martin-g and @KalleOlaviNiemitalo ! I've incorporated your review feedback.
@KalleOlaviNiemitalo , I've renamed the existing method as `ParseInternal` as you suggested, and added a public method that calls it after performing argument null checks and json trimming.
Yes, I plan to use this method in https://github.com/confluentinc/confluent-kafka-dotnet , since Confluent Schema Registry supports Avro schemas that can reference other schemas by name. This allows schema reuse, as well as allows our customers to decompose very Avro large schemas into smaller ones.
As suggested, I've added an example of how I intend to use this method. The test has a root schema that refers to a nested schema by name only. In Confluent Schema Registry we also store some metadata with the root schema to indicate which schema(s) it refers to. The Schema Registry client in https://github.com/confluentinc/confluent-kafka-dotnet will retrieve both schemas independently, and then use the method in this PR to reconstruct the root schema.
I've implemented this functionality for Schema Registry clients written in Java, go, Python, and Node.js, since the Avro libraries in those other languages also provide a means to compose schemas by name. This PR will allow C# to provide the same capability.
Please let me know if you would like me to add anything else to my explanation or this PR. Thanks in advance!
--
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 4091: [C#] Allow previously parsed schemas to be referenced when parsing a schema [avro]
Posted by "rayokota (via GitHub)" <gi...@apache.org>.
rayokota commented on PR #3242:
URL: https://github.com/apache/avro/pull/3242#issuecomment-2484635908
@martin-g @KalleOlaviNiemitalo @zcsizmadia could I kindly get a review? Thanks in advance!
--
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 4091: [C#] Allow previously parsed schemas to be referenced when parsing a schema [avro]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on PR #3242:
URL: https://github.com/apache/avro/pull/3242#issuecomment-2484835396
I am not familiar with C# and/or the Avro C# SDK ...
The change is trivial so I enabled the CI checks, but I cannot say whether the change is a good one or not. There are no new tests verifying the problem or the fix.
--
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 4091: [C#] Allow previously parsed schemas to be referenced when parsing a schema [avro]
Posted by "KalleOlaviNiemitalo (via GitHub)" <gi...@apache.org>.
KalleOlaviNiemitalo commented on PR #3242:
URL: https://github.com/apache/avro/pull/3242#issuecomment-2484875077
@rayokota, are you planning a change in <https://github.com/confluentinc/confluent-kafka-dotnet> that would make use of this public method? If you can post that as a draft PR there, it will be easier to understand what the benefit is.
--
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 4091: [C#] Allow previously parsed schemas to be referenced when parsing a schema [avro]
Posted by "KalleOlaviNiemitalo (via GitHub)" <gi...@apache.org>.
KalleOlaviNiemitalo commented on PR #3242:
URL: https://github.com/apache/avro/pull/3242#issuecomment-2484891553
If the method becomes public, then it should have argument null checks and trimming like in Parse(string json).
To avoid redundant checks and trimming when the caller has already done those, one could rename the existing `internal static Schema Parse(string json, SchemaNames names, string encspace)` to ParseInternal and add a public Parse wrapper with the checks and trimming.
--
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