-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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
[SPARK-16648][SQL] Make ignoreNullsExpr a child expression of First and Last #14295
Conversation
Test build #62654 has finished for PR 14295 at commit
|
@@ -42,6 +42,17 @@ case class Last(child: Expression, ignoreNullsExpr: Expression) extends Declarat | |||
|
|||
override def children: Seq[Expression] = child :: Nil | |||
|
|||
// SPARK-16648: Default `TreeNode.withNewChildren` implementation doesn't work for `Last` when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use [[
to reference code symbols.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a ScalaDoc comment, so [[...]]
is not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's probably unnecessary, since expressions are not part of the public API and won't appear in the generated ScalaDoc anyway...
@liancheng Can you also change |
Oh, that's a good point, should have realized both of them are affected. Updated. Thanks! |
Test build #62750 has finished for PR 14295 at commit
|
@@ -45,6 +45,17 @@ case class First(child: Expression, ignoreNullsExpr: Expression) extends Declara | |||
|
|||
override def children: Seq[Expression] = child :: Nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we make ignoreNullsExpr
also a child?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, this looks like a cleaner fix. Let me try whether it breaks anything else. Thanks!
Tried to make |
Test build #62799 has finished for PR 14295 at commit
|
LGTM |
…nd Last ## What changes were proposed in this pull request? Default `TreeNode.withNewChildren` implementation doesn't work for `Last` and when both constructor arguments are the same, e.g.: ```sql LAST_VALUE(FALSE) -- The 2nd argument defaults to FALSE LAST_VALUE(FALSE, FALSE) LAST_VALUE(TRUE, TRUE) ``` This is because although `Last` is a unary expression, both of its constructor arguments, `child` and `ignoreNullsExpr`, are `Expression`s. When they have the same value, `TreeNode.withNewChildren` treats both of them as child nodes by mistake. `First` is also affected by this issue in exactly the same way. This PR fixes this issue by making `ignoreNullsExpr` a child expression of `First` and `Last`. ## How was this patch tested? New test case added in `WindowQuerySuite`. Author: Cheng Lian <lian@databricks.com> Closes #14295 from liancheng/spark-16648-last-value. (cherry picked from commit 68b4020) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
thanks, merging to master/2.0! |
What changes were proposed in this pull request?
Default
TreeNode.withNewChildren
implementation doesn't work forLast
and when both constructor arguments are the same, e.g.:LAST_VALUE(FALSE) -- The 2nd argument defaults to FALSE LAST_VALUE(FALSE, FALSE) LAST_VALUE(TRUE, TRUE)
This is because although
Last
is a unary expression, both of its constructor arguments,child
andignoreNullsExpr
, areExpression
s. When they have the same value,TreeNode.withNewChildren
treats both of them as child nodes by mistake.First
is also affected by this issue in exactly the same way.This PR fixes this issue by making
ignoreNullsExpr
a child expression ofFirst
andLast
.How was this patch tested?
New test case added in
WindowQuerySuite
.