You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "marvinlanhenke (via GitHub)" <gi...@apache.org> on 2023/12/22 11:56:37 UTC

[PR] Fix #8507: Non-null sub-field on nullable struct-field has wrong nullity [arrow-datafusion]

marvinlanhenke opened a new pull request, #8623:
URL: https://github.com/apache/arrow-datafusion/pull/8623

   ## 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 #8507.
   
   ## 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.  
   -->
   If parent struct is nullable; sub-fields should also be.
   
   ## 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.
   -->
   
   As suggested in #8507: 
   I added a test to reproduce the bug with the schema described.
   Then I introduced a simple guard clause to check if the parent col is nullable; if it is return early.
   
   ## Are these changes tested?
   Change is tested by `test_nested_schema_nullability`.
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   No.
   <!--
   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 `api 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


Re: [PR] Fix #8507: Non-null sub-field on nullable struct-field has wrong nullity [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #8623:
URL: https://github.com/apache/arrow-datafusion/pull/8623


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


Re: [PR] Fix #8507: Non-null sub-field on nullable struct-field has wrong nullity [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8623:
URL: https://github.com/apache/arrow-datafusion/pull/8623#issuecomment-1868076635

   @marvinlanhenke  it looks like there is a clippy error preventing a clean CI run: https://github.com/apache/arrow-datafusion/actions/runs/7299570999/job/19905117841?pr=8623
   
   Is there any chance you can fix that so we can merge this PR?


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


Re: [PR] Fix #8507: Non-null sub-field on nullable struct-field has wrong nullity [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8623:
URL: https://github.com/apache/arrow-datafusion/pull/8623#issuecomment-1868281194

   THanks again @marvinlanhenke 


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


Re: [PR] Fix #8507: Non-null sub-field on nullable struct-field has wrong nullity [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #8623:
URL: https://github.com/apache/arrow-datafusion/pull/8623#discussion_r1435346130


##########
datafusion/expr/src/expr_schema.rs:
##########
@@ -548,6 +555,27 @@ mod tests {
         assert_eq!(&meta, expr.to_field(&schema).unwrap().metadata());
     }
 
+    #[test]
+    fn test_nested_schema_nullability() {
+        let fields = DFField::new(
+            Some(TableReference::Bare {
+                table: "table_name".into(),
+            }),
+            "parent",
+            DataType::Struct(Fields::from(vec![Field::new(
+                "child",
+                DataType::Int64,
+                false,
+            )])),
+            true,
+        );
+
+        let schema = DFSchema::new_with_metadata(vec![fields], HashMap::new()).unwrap();
+
+        let expr = col("parent").field("child");
+        assert_eq!(expr.nullable(&schema).unwrap(), true);

Review Comment:
   👍 



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


Re: [PR] Fix #8507: Non-null sub-field on nullable struct-field has wrong nullity [arrow-datafusion]

Posted by "marvinlanhenke (via GitHub)" <gi...@apache.org>.
marvinlanhenke commented on PR #8623:
URL: https://github.com/apache/arrow-datafusion/pull/8623#issuecomment-1868201613

   @alamb thanks for the approval - i just committed the `clippy-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: github-unsubscribe@arrow.apache.org

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