You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/05/09 06:21:39 UTC

[GitHub] [arrow-rs] viirya opened a new pull request, #1677: Fix generate_unions_case for Rust case

viirya opened a new pull request, #1677:
URL: https://github.com/apache/arrow-rs/pull/1677

   # Which issue does this PR close?
   
   <!---
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #1676.
   
   # Rationale for this change
    
    <!---
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   # What changes are included in this PR?
   
   <!---
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   
   <!---
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on a diff in pull request #1677: Fix generate_unions_case for Rust case

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #1677:
URL: https://github.com/apache/arrow-rs/pull/1677#discussion_r869678255


##########
arrow/src/datatypes/datatype.rs:
##########
@@ -499,6 +499,52 @@ impl DataType {
                         ))
                     }
                 }
+                Some(s) if s == "union" => {
+                    if let Some(Value::String(mode)) = map.get("mode") {
+                        let union_mode = if mode == "SPARSE" {
+                            UnionMode::Sparse
+                        } else if mode == "DENSE" {
+                            UnionMode::Dense
+                        } else {
+                            return Err(ArrowError::ParseError(format!(
+                                "Unknown union mode {:?} for union",
+                                mode
+                            )));
+                        };
+                        if let Some(type_ids) = map.get("typeIds") {
+                            let type_ids = type_ids
+                                .as_array()
+                                .unwrap()
+                                .iter()
+                                .map(|t| t.as_i64().unwrap())
+                                .collect::<Vec<_>>();
+
+                            let default_fields = type_ids
+                                .iter()
+                                .map(|t| {
+                                    Field::new("", DataType::Boolean, true).with_metadata(

Review Comment:
   This is because, `type` (union, map, list, etc) is defined in "type" of the Json map, fields are defined in "children" of the map. We parse "type" to get the nested type and parse "children" to get actual fields after that. 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on pull request #1677: Fix generate_unions_case for Rust case

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #1677:
URL: https://github.com/apache/arrow-rs/pull/1677#issuecomment-1123019892

   Merged, thanks @alamb !


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] alamb commented on a diff in pull request #1677: Fix generate_unions_case for Rust case

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #1677:
URL: https://github.com/apache/arrow-rs/pull/1677#discussion_r870122518


##########
arrow/src/datatypes/datatype.rs:
##########
@@ -499,6 +499,52 @@ impl DataType {
                         ))
                     }
                 }
+                Some(s) if s == "union" => {
+                    if let Some(Value::String(mode)) = map.get("mode") {
+                        let union_mode = if mode == "SPARSE" {
+                            UnionMode::Sparse
+                        } else if mode == "DENSE" {
+                            UnionMode::Dense
+                        } else {
+                            return Err(ArrowError::ParseError(format!(
+                                "Unknown union mode {:?} for union",
+                                mode
+                            )));
+                        };
+                        if let Some(type_ids) = map.get("typeIds") {
+                            let type_ids = type_ids
+                                .as_array()
+                                .unwrap()
+                                .iter()
+                                .map(|t| t.as_i64().unwrap())
+                                .collect::<Vec<_>>();
+
+                            let default_fields = type_ids
+                                .iter()
+                                .map(|t| {
+                                    Field::new("", DataType::Boolean, true).with_metadata(

Review Comment:
   Thanks for the explanation
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on a diff in pull request #1677: Fix generate_unions_case for Rust case

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #1677:
URL: https://github.com/apache/arrow-rs/pull/1677#discussion_r869676095


##########
arrow/src/datatypes/datatype.rs:
##########
@@ -499,6 +499,52 @@ impl DataType {
                         ))
                     }
                 }
+                Some(s) if s == "union" => {
+                    if let Some(Value::String(mode)) = map.get("mode") {
+                        let union_mode = if mode == "SPARSE" {
+                            UnionMode::Sparse
+                        } else if mode == "DENSE" {
+                            UnionMode::Dense
+                        } else {
+                            return Err(ArrowError::ParseError(format!(
+                                "Unknown union mode {:?} for union",
+                                mode
+                            )));
+                        };
+                        if let Some(type_ids) = map.get("typeIds") {
+                            let type_ids = type_ids
+                                .as_array()
+                                .unwrap()
+                                .iter()
+                                .map(|t| t.as_i64().unwrap())
+                                .collect::<Vec<_>>();
+
+                            let default_fields = type_ids
+                                .iter()
+                                .map(|t| {
+                                    Field::new("", DataType::Boolean, true).with_metadata(

Review Comment:
   This is only a placeholder, as above other nested types (list, map, etc) do. The actual fields will replace them (`Field::from`). 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya merged pull request #1677: Fix generate_unions_case for Rust case

Posted by GitBox <gi...@apache.org>.
viirya merged PR #1677:
URL: https://github.com/apache/arrow-rs/pull/1677


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on a diff in pull request #1677: Fix generate_unions_case for Rust case

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #1677:
URL: https://github.com/apache/arrow-rs/pull/1677#discussion_r868183199


##########
arrow/src/datatypes/datatype.rs:
##########
@@ -499,6 +499,52 @@ impl DataType {
                         ))
                     }
                 }
+                Some(s) if s == "union" => {

Review Comment:
   We don't parse union type from json before.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on a diff in pull request #1677: Fix generate_unions_case for Rust case

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #1677:
URL: https://github.com/apache/arrow-rs/pull/1677#discussion_r868547408


##########
arrow/src/datatypes/mod.rs:
##########
@@ -392,6 +392,70 @@ mod tests {
         assert_eq!(expected, dt);
     }
 
+    #[test]
+    fn parse_union_from_json() {

Review Comment:
   I will work on union to json in another PR later.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] alamb commented on a diff in pull request #1677: Fix generate_unions_case for Rust case

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #1677:
URL: https://github.com/apache/arrow-rs/pull/1677#discussion_r869664364


##########
arrow/src/datatypes/datatype.rs:
##########
@@ -499,6 +499,52 @@ impl DataType {
                         ))
                     }
                 }
+                Some(s) if s == "union" => {
+                    if let Some(Value::String(mode)) = map.get("mode") {
+                        let union_mode = if mode == "SPARSE" {
+                            UnionMode::Sparse
+                        } else if mode == "DENSE" {
+                            UnionMode::Dense
+                        } else {
+                            return Err(ArrowError::ParseError(format!(
+                                "Unknown union mode {:?} for union",
+                                mode
+                            )));
+                        };
+                        if let Some(type_ids) = map.get("typeIds") {
+                            let type_ids = type_ids
+                                .as_array()
+                                .unwrap()
+                                .iter()
+                                .map(|t| t.as_i64().unwrap())
+                                .collect::<Vec<_>>();
+
+                            let default_fields = type_ids
+                                .iter()
+                                .map(|t| {
+                                    Field::new("", DataType::Boolean, true).with_metadata(

Review Comment:
   is it cool to have a field without a name 🤔 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] codecov-commenter commented on pull request #1677: Fix generate_unions_case for Rust case

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #1677:
URL: https://github.com/apache/arrow-rs/pull/1677#issuecomment-1120704412

   # [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/1677?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1677](https://codecov.io/gh/apache/arrow-rs/pull/1677?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2883adc) into [master](https://codecov.io/gh/apache/arrow-rs/commit/03ab9a3a60445431e248972acea3c2775858a706?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (03ab9a3) will **decrease** coverage by `0.09%`.
   > The diff coverage is `0.00%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1677      +/-   ##
   ==========================================
   - Coverage   83.10%   83.01%   -0.10%     
   ==========================================
     Files         193      193              
     Lines       55881    55940      +59     
   ==========================================
   - Hits        46439    46436       -3     
   - Misses       9442     9504      +62     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/arrow-rs/pull/1677?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [arrow/src/datatypes/datatype.rs](https://codecov.io/gh/apache/arrow-rs/pull/1677/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2RhdGF0eXBlcy9kYXRhdHlwZS5ycw==) | `60.36% <0.00%> (-6.04%)` | :arrow_down: |
   | [arrow/src/datatypes/field.rs](https://codecov.io/gh/apache/arrow-rs/pull/1677/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2RhdGF0eXBlcy9maWVsZC5ycw==) | `54.21% <0.00%> (-2.23%)` | :arrow_down: |
   | [arrow/src/util/integration\_util.rs](https://codecov.io/gh/apache/arrow-rs/pull/1677/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL3V0aWwvaW50ZWdyYXRpb25fdXRpbC5ycw==) | `68.53% <ø> (ø)` | |
   | [integration-testing/src/lib.rs](https://codecov.io/gh/apache/arrow-rs/pull/1677/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW50ZWdyYXRpb24tdGVzdGluZy9zcmMvbGliLnJz) | `0.00% <0.00%> (ø)` | |
   | [arrow/src/array/transform/mod.rs](https://codecov.io/gh/apache/arrow-rs/pull/1677/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L3RyYW5zZm9ybS9tb2QucnM=) | `86.57% <0.00%> (-0.12%)` | :arrow_down: |
   | [arrow/src/array/array\_binary.rs](https://codecov.io/gh/apache/arrow-rs/pull/1677/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2FycmF5X2JpbmFyeS5ycw==) | `93.30% <0.00%> (ø)` | |
   | [arrow/src/array/array\_string.rs](https://codecov.io/gh/apache/arrow-rs/pull/1677/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2FycmF5X3N0cmluZy5ycw==) | `97.73% <0.00%> (ø)` | |
   | [arrow/src/array/array\_list.rs](https://codecov.io/gh/apache/arrow-rs/pull/1677/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2FycmF5L2FycmF5X2xpc3QucnM=) | `96.16% <0.00%> (+0.37%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/arrow-rs/pull/1677?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/1677?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [03ab9a3...2883adc](https://codecov.io/gh/apache/arrow-rs/pull/1677?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org