Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct schema nullability declaration in tests #2802

Merged
merged 1 commit into from Jun 28, 2022

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jun 27, 2022

Which issue does this PR close?

Part of #2778

Rationale for this change

apache/arrow-rs#1888 (added in arrow 17.0.0) added validation to RecordBatch if the schema's declared nullability is different than its actual nullability it throws a runtime error.

What changes are included in this PR?

Correct declared schema nullability in DataFusion tests .

There are no tests in this PR -- they are covered in #2778

Are there any user-facing changes?

No, it is a test only change

@github-actions github-actions bot added core Core datafusion crate physical-expr Physical Expressions labels Jun 27, 2022
@alamb alamb mentioned this pull request Jun 27, 2022
6 tasks
Field::new("a", DataType::Int32, false),
Field::new("b", DataType::Int32, false),
Field::new("a", DataType::Int32, true),
Field::new("b", DataType::Int32, true),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty easy to understand example of the issue -- prior to this PR, the fields "a" and "b" are declared as "nullable=false" but then 5 lines lower NULL data is inserted 🤦

        let batch = RecordBatch::try_new(
            Arc::clone(&schema),
            vec![
                Arc::new(Int32Array::from(vec![Some(1), Some(2), None])),
                Arc::new(Int32Array::from(vec![Some(4), None, Some(6)])),
            ],
        )?;

Now that RecordBatch::try_new validates the nullability, the schema must match the data otherwise an error results

@alamb alamb requested a review from andygrove June 27, 2022 23:07
@codecov-commenter
Copy link

Codecov Report

Merging #2802 (b6e898c) into master (533e2b4) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head b6e898c differs from pull request most recent head 5dc0e51. Consider uploading reports for the commit 5dc0e51 to get more accurate results

@@            Coverage Diff             @@
##           master    #2802      +/-   ##
==========================================
- Coverage   85.11%   85.11%   -0.01%     
==========================================
  Files         273      273              
  Lines       48240    48240              
==========================================
- Hits        41060    41059       -1     
- Misses       7180     7181       +1     
Impacted Files Coverage Δ
...fusion/physical-expr/src/aggregate/sum_distinct.rs 92.66% <ø> (ø)
datafusion/physical-expr/src/expressions/cast.rs 98.00% <ø> (ø)
datafusion/physical-expr/src/expressions/mod.rs 100.00% <ø> (ø)
...tafusion/physical-expr/src/expressions/try_cast.rs 98.75% <ø> (ø)
datafusion/core/src/datasource/listing/helpers.rs 95.30% <100.00%> (ø)
...ore/src/physical_optimizer/aggregate_statistics.rs 100.00% <100.00%> (ø)
datafusion/core/src/physical_plan/hash_join.rs 94.68% <100.00%> (ø)
datafusion/core/src/physical_plan/memory.rs 96.03% <100.00%> (ø)
...afusion/physical-expr/src/aggregate/correlation.rs 97.97% <100.00%> (ø)
...tafusion/physical-expr/src/aggregate/covariance.rs 98.71% <100.00%> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 533e2b4...5dc0e51. Read the comment docs.

@andygrove andygrove merged commit 93d985c into apache:master Jun 28, 2022
@alamb alamb deleted the alamb/correct_nullability branch June 28, 2022 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core datafusion crate physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants