You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "matthewgapp (via GitHub)" <gi...@apache.org> on 2023/09/24 22:33:50 UTC
[GitHub] [arrow-datafusion] matthewgapp opened a new pull request, #7638: add nullability information to window function
matthewgapp opened a new pull request, #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638
add nullability information to window function that is used to determine expression and thus column nullability when constructing window plan
## 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 #7636
## 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 these changes tested?
<!--
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?
<!--
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
[GitHub] [arrow-datafusion] matthewgapp commented on a diff in pull request #7638: add nullability information to window function
Posted by "matthewgapp (via GitHub)" <gi...@apache.org>.
matthewgapp commented on code in PR #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638#discussion_r1335314984
##########
datafusion/sqllogictest/test_files/window.slt:
##########
@@ -3315,3 +3315,23 @@ SELECT
window1 AS (ORDER BY C3)
ORDER BY C3
LIMIT 5
+
+# Create table with window functions that have nullable: false columns should result in correct schema during cross join
Review Comment:
Note that I couldn't include a test for the `NTILE` window function because it failed. I filed a separate bug [here](https://github.com/apache/arrow-datafusion/issues/7639)
--
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-datafusion] matthewgapp commented on a diff in pull request #7638: add nullability information to window function
Posted by "matthewgapp (via GitHub)" <gi...@apache.org>.
matthewgapp commented on code in PR #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638#discussion_r1335314634
##########
datafusion/sqllogictest/test_files/window.slt:
##########
@@ -3315,3 +3315,23 @@ SELECT
window1 AS (ORDER BY C3)
ORDER BY C3
LIMIT 5
+
+# Create table with window functions that have nullable: false columns should result in correct schema during cross join
Review Comment:
these tests fail on `main`
##########
datafusion/sqllogictest/test_files/window.slt:
##########
@@ -3315,3 +3315,23 @@ SELECT
window1 AS (ORDER BY C3)
ORDER BY C3
LIMIT 5
+
+# Create table with window functions that have nullable: false columns should result in correct schema during cross join
Review Comment:
these tests fail on `main` but pass on this branch as expected.
--
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-datafusion] matthewgapp commented on a diff in pull request #7638: mark appropriate window functions as nullable: false in logical plan
Posted by "matthewgapp (via GitHub)" <gi...@apache.org>.
matthewgapp commented on code in PR #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638#discussion_r1338752948
##########
datafusion/sqllogictest/test_files/window.slt:
##########
@@ -3315,3 +3315,23 @@ SELECT
window1 AS (ORDER BY C3)
ORDER BY C3
LIMIT 5
+
+# Create table with window functions that have nullable: false columns should result in correct schema during cross join
Review Comment:
Note that as of arrow `47.0.0`, these tests will no longer fail because arrow no longer checks schema nullability. For more context, see https://github.com/apache/arrow-datafusion/issues/7636#issuecomment-1737225422.
To that end, I should introduce tests that explicitly check the logical schema for `nullable: false` when we expect it to be (e.g., for columns created via row_number(), rank(), etc). I'll get around to this tonight.
--
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] mark appropriate window functions as nullable: false in logical plan [datafusion]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #7638: mark appropriate window functions as nullable: false in logical plan
URL: https://github.com/apache/datafusion/pull/7638
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
[GitHub] [arrow-datafusion] alamb commented on pull request #7638: add nullability information to window function
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638#issuecomment-1737304251
See https://github.com/apache/arrow-datafusion/issues/7636#issuecomment-1737225422
--
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-datafusion] matthewgapp commented on a diff in pull request #7638: mark appropriate window functions as nullable: false in logical plan
Posted by "matthewgapp (via GitHub)" <gi...@apache.org>.
matthewgapp commented on code in PR #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638#discussion_r1338752948
##########
datafusion/sqllogictest/test_files/window.slt:
##########
@@ -3315,3 +3315,23 @@ SELECT
window1 AS (ORDER BY C3)
ORDER BY C3
LIMIT 5
+
+# Create table with window functions that have nullable: false columns should result in correct schema during cross join
Review Comment:
Note that starting with version 47.0.0 of Arrow, the tests referenced will no longer fail (without the fixes provided in this PR) because Arrow has stopped checking for schema nullability. For more context, visit [issue comment](https://github.com/apache/arrow-datafusion/issues/7636#issuecomment-1737225422).
Therefore, I plan to introduce tests that explicitly check for nullable: false in the logical schema where it is expected, such as in columns created via row_number(), rank(), and similar functions. I will address this tonight.
--
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-datafusion] matthewgapp commented on a diff in pull request #7638: add nullability information to window function
Posted by "matthewgapp (via GitHub)" <gi...@apache.org>.
matthewgapp commented on code in PR #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638#discussion_r1335255123
##########
datafusion/expr/src/window_function.rs:
##########
@@ -114,19 +114,35 @@ pub enum BuiltInWindowFunction {
impl BuiltInWindowFunction {
fn name(&self) -> &str {
- use BuiltInWindowFunction::*;
+ use BuiltInWindowFunction as F;
match self {
- RowNumber => "ROW_NUMBER",
- Rank => "RANK",
- DenseRank => "DENSE_RANK",
- PercentRank => "PERCENT_RANK",
- CumeDist => "CUME_DIST",
- Ntile => "NTILE",
- Lag => "LAG",
- Lead => "LEAD",
- FirstValue => "FIRST_VALUE",
- LastValue => "LAST_VALUE",
- NthValue => "NTH_VALUE",
+ F::RowNumber => "ROW_NUMBER",
+ F::Rank => "RANK",
+ F::DenseRank => "DENSE_RANK",
+ F::PercentRank => "PERCENT_RANK",
+ F::CumeDist => "CUME_DIST",
+ F::Ntile => "NTILE",
+ F::Lag => "LAG",
+ F::Lead => "LEAD",
+ F::FirstValue => "FIRST_VALUE",
+ F::LastValue => "LAST_VALUE",
+ F::NthValue => "NTH_VALUE",
+ }
+ }
+
+ // these values need to stay in sync with the `field` value defined on the physical expressions
+ pub fn nullable(&self) -> bool {
+ use BuiltInWindowFunction as F;
+ match self {
+ F::RowNumber | F::Ntile | F::Rank | F::CumeDist => false,
+ // the rest are assumed to be nullable
Review Comment:
not sure if there is a way that we can derive this from the definitions of the physical plans or elsewhere? Kinda sucks to have this information hardcoded this information in two places (right now, it exists also in the `field` method definition on the `BuildInWindowFunctionExpr` trait ([example](https://github.com/apache/arrow-datafusion/blob/78d9613e81557ca5e5db8b75e5c7dec47ccee0a1/datafusion/physical-expr/src/window/row_number.rs#L54))
--
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] mark appropriate window functions as nullable: false in logical plan [datafusion]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7638:
URL: https://github.com/apache/datafusion/pull/7638#issuecomment-2081765880
Thank you for your contribution. Unfortunately, this pull request is stale because it has been open 60 days with no activity. Please remove the stale label or comment or this will be closed in 7 days.
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
[GitHub] [arrow-datafusion] alamb commented on pull request #7638: add nullability information to window function
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638#issuecomment-1734456833
Related comment: https://github.com/apache/arrow-datafusion/issues/7636#issuecomment-1734455977
--
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-datafusion] matthewgapp commented on a diff in pull request #7638: mark appropriate window functions as nullable: false in logical plan
Posted by "matthewgapp (via GitHub)" <gi...@apache.org>.
matthewgapp commented on code in PR #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638#discussion_r1338752948
##########
datafusion/sqllogictest/test_files/window.slt:
##########
@@ -3315,3 +3315,23 @@ SELECT
window1 AS (ORDER BY C3)
ORDER BY C3
LIMIT 5
+
+# Create table with window functions that have nullable: false columns should result in correct schema during cross join
Review Comment:
Note that as of arrow `47.0.0`, these tests will no longer fail (absent the fixes in this PR) because arrow no longer checks schema nullability. For more context, see https://github.com/apache/arrow-datafusion/issues/7636#issuecomment-1737225422.
To that end, I should introduce tests that explicitly check the logical schema for `nullable: false` when we expect it to be (e.g., for columns created via row_number(), rank(), etc). I'll get around to this tonight.
--
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-datafusion] matthewgapp commented on a diff in pull request #7638: add nullability information to window function
Posted by "matthewgapp (via GitHub)" <gi...@apache.org>.
matthewgapp commented on code in PR #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638#discussion_r1335254972
##########
datafusion/expr/src/window_function.rs:
##########
@@ -114,19 +114,35 @@ pub enum BuiltInWindowFunction {
impl BuiltInWindowFunction {
fn name(&self) -> &str {
- use BuiltInWindowFunction::*;
+ use BuiltInWindowFunction as F;
Review Comment:
flyby fix. Using wildcard here means that if a variant were deleted from the enum, the bottom-most variant in the match statement would become a variable catch-all.
--
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-datafusion] alamb commented on pull request #7638: mark appropriate window functions as nullable: false in logical plan
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #7638:
URL: https://github.com/apache/arrow-datafusion/pull/7638#issuecomment-1742040574
Marking as draft as I think https://github.com/apache/arrow-datafusion/pull/7694 may be fixing the root cause instead
--
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