You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "sarutak (via GitHub)" <gi...@apache.org> on 2023/07/16 18:27:16 UTC

[GitHub] [avro] sarutak opened a new pull request, #2352: AVRO-3799: [Rust] Enable the schema parser to read and parse from input streams for Rust binding

sarutak opened a new pull request, #2352:
URL: https://github.com/apache/avro/pull/2352

   <!--
   
   *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
   
   This PR proposes to add a feature which enables to create schemas from input streams which implement `Read` trait like `std::fs::File`.
   The Java binding supports to create schemas from input streams. So, it's useful to have such a feature for the Rust binding too.
   
   ## Verifying this change
   
   This change adds new tests to `tests/schema.rs` and `cargo test` passed.
   
   ## Documentation
   
   Doc comments added.
   


-- 
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] martin-g commented on a diff in pull request #2352: AVRO-3799: [Rust] Enable the schema parser to read and parse from input streams for Rust binding

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #2352:
URL: https://github.com/apache/avro/pull/2352#discussion_r1264735881


##########
lang/rust/avro/tests/schema.rs:
##########
@@ -682,6 +684,61 @@ fn test_parse() -> TestResult {
     Ok(())
 }
 
+#[test]
+fn test_parse_reader() -> TestResult {

Review Comment:
   ```suggestion
   fn avro_3799_test_parse_reader() -> TestResult {
   ```



##########
lang/rust/avro/tests/schema.rs:
##########
@@ -682,6 +684,61 @@ fn test_parse() -> TestResult {
     Ok(())
 }
 
+#[test]
+fn test_parse_reader() -> TestResult {
+    init();
+    for (raw_schema, valid) in EXAMPLES.iter() {
+        let schema = Schema::parse_reader(&mut Cursor::new(raw_schema));
+        if *valid {
+            assert!(
+                schema.is_ok(),
+                "schema {raw_schema} was supposed to be valid; error: {schema:?}",
+            )
+        } else {
+            assert!(
+                schema.is_err(),
+                "schema {raw_schema} was supposed to be invalid"
+            )
+        }
+    }
+
+    // Ensure it works for trait objects too.
+    for (raw_schema, valid) in EXAMPLES.iter() {
+        let reader: &mut dyn Read = &mut Cursor::new(raw_schema);
+        let schema = Schema::parse_reader(reader);
+        if *valid {
+            assert!(
+                schema.is_ok(),
+                "schema {raw_schema} was supposed to be valid; error: {schema:?}",
+            )
+        } else {
+            assert!(
+                schema.is_err(),
+                "schema {raw_schema} was supposed to be invalid"
+            )
+        }
+    }
+    Ok(())
+}
+
+#[test]
+fn test_raise_io_error_from_parse_read() -> Result<(), String> {

Review Comment:
   ```suggestion
   fn avro_3799_test_raise_io_error_from_parse_read() -> Result<(), String> {
   ```



-- 
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] martin-g merged pull request #2352: AVRO-3799: [Rust] Enable the schema parser to read and parse from input streams for Rust binding

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g merged PR #2352:
URL: https://github.com/apache/avro/pull/2352


-- 
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] sarutak commented on pull request #2352: AVRO-3799: [Rust] Enable the schema parser to read and parse from input streams for Rust binding

Posted by "sarutak (via GitHub)" <gi...@apache.org>.
sarutak commented on PR #2352:
URL: https://github.com/apache/avro/pull/2352#issuecomment-1637531759

   @martin-g Thank you for merging this!


-- 
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] martin-g commented on pull request #2352: AVRO-3799: [Rust] Enable the schema parser to read and parse from input streams for Rust binding

Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on PR #2352:
URL: https://github.com/apache/avro/pull/2352#issuecomment-1637448383

   Thank you, @sarutak !


-- 
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