[SQL] Simplifies binary node pattern matching#6537
[SQL] Simplifies binary node pattern matching#6537liancheng wants to merge 3 commits intoapache:masterfrom
Conversation
d4922e9 to
d4c48fb
Compare
There was a problem hiding this comment.
This is made uppercase so that it's not recognized as a free variable in pattern matching.
|
@yhuai @rxin If this looks good to you, we may merge this after #6405 and #6505 to avoid unnecessary merging conflicts for @cloud-fan. |
|
Ah, just realized that @cloud-fan also adds |
There was a problem hiding this comment.
Existing: why we swap the order here? StringNaN is at left but we put Literal(Double.NaN) at right. Did I missed something here?
There was a problem hiding this comment.
Yeah, I also wondered for a while when updating this. But I think the order is irrelevant here.
There was a problem hiding this comment.
let's do the minimum thing needed and not switch the order here. No need to confuse the future user why orders are switched.
There was a problem hiding this comment.
The order was switched in the original code, and this PR respects that. I kinda tend to switch it back to the "normal" way.
There was a problem hiding this comment.
Yea let's just switch it. BTW this PR conflicts pretty heavily with @cloud-fan's right?
There was a problem hiding this comment.
Yeah, they conflict, but not super heavily. That's why I suggested merging his PRs first and then this one.
|
Test build #33849 has finished for PR 6537 at commit
|
There was a problem hiding this comment.
unrelated to this pr, but i find 'l" somewhat hard to differentiate from "1". might be better in the future to use left vs right
There was a problem hiding this comment.
actually it is related to this pr .. we didn't have l and r before :)
There was a problem hiding this comment.
Thanks, will update.
|
Test build #33874 has finished for PR 6537 at commit
|
f83d282 to
17c5ea5
Compare
There was a problem hiding this comment.
Oops, these were introduced while rebasing, thanks!
3e06036 to
188028f
Compare
|
Test build #33893 has finished for PR 6537 at commit
|
|
Test build #33896 has finished for PR 6537 at commit
|
|
Test build #33898 has finished for PR 6537 at commit
|
188028f to
6b1b915
Compare
|
Test build #34169 has finished for PR 6537 at commit
|
6b1b915 to
a3bf5fe
Compare
|
Test build #34272 has finished for PR 6537 at commit
|
This PR is a simpler version of apache#2764, and adds `unapply` methods to the following binary nodes for simpler pattern matching: - `BinaryExpression` - `BinaryComparison` - `BinaryArithmetics` This enables nested pattern matching for binary nodes. For example, the following pattern matching ```scala case p: BinaryComparison if p.left.dataType == StringType && p.right.dataType == DateType => p.makeCopy(Array(p.left, Cast(p.right, StringType))) ``` can be simplified to ```scala case p BinaryComparison(l StringType(), r DateType()) => p.makeCopy(Array(l, Cast(r, StringType))) ``` Author: Cheng Lian <lian@databricks.com> Closes apache#6537 from liancheng/binary-node-patmat and squashes the following commits: a3bf5fe [Cheng Lian] Fixes compilation error introduced while rebasing b738986 [Cheng Lian] Renames `l`/`r` to `left`/`right` or `lhs`/`rhs` 14900ae [Cheng Lian] Simplifies binary node pattern matching
This PR is a simpler version of apache#2764, and adds `unapply` methods to the following binary nodes for simpler pattern matching: - `BinaryExpression` - `BinaryComparison` - `BinaryArithmetics` This enables nested pattern matching for binary nodes. For example, the following pattern matching ```scala case p: BinaryComparison if p.left.dataType == StringType && p.right.dataType == DateType => p.makeCopy(Array(p.left, Cast(p.right, StringType))) ``` can be simplified to ```scala case p BinaryComparison(l StringType(), r DateType()) => p.makeCopy(Array(l, Cast(r, StringType))) ``` Author: Cheng Lian <lian@databricks.com> Closes apache#6537 from liancheng/binary-node-patmat and squashes the following commits: a3bf5fe [Cheng Lian] Fixes compilation error introduced while rebasing b738986 [Cheng Lian] Renames `l`/`r` to `left`/`right` or `lhs`/`rhs` 14900ae [Cheng Lian] Simplifies binary node pattern matching
This PR is a simpler version of #2764, and adds
unapplymethods to the following binary nodes for simpler pattern matching:BinaryExpressionBinaryComparisonBinaryArithmeticsThis enables nested pattern matching for binary nodes. For example, the following pattern matching
can be simplified to