[SQL] Refactors data type pattern matching#2764
[SQL] Refactors data type pattern matching#2764liancheng wants to merge 2 commits intoapache:masterfrom
Conversation
|
Can one of the admins verify this patch? |
|
QA tests have started for PR 2764 at commit
|
|
QA tests have finished for PR 2764 at commit
|
|
Test PASSed. |
There was a problem hiding this comment.
This case branch can never be reached since line 114 supersedes it. As a result, "NaN" is always Double, bug?
There was a problem hiding this comment.
Yes, this is probably a copy paste bug.
|
This does look like a better style that what we were doing before. We should coordinate with the changes @mateiz is making for decimal type. |
f391be5 to
f938a6b
Compare
There was a problem hiding this comment.
Why are these type parameterized? Things seems to compile without this added complexity. Extra refinement can be done regardless with nested pattern matching.
There was a problem hiding this comment.
Right, this type parameter can be removed. Thanks.
3653407 to
0ea4690
Compare
|
Rebased to master. |
0ea4690 to
c393456
Compare
|
Sorry for the delay here. I think it would be good to clean up how we do pattern matching and this looks like a good start. Here's what I propose:
|
This PR is a simpler version of #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 #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 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
Refactors/adds extractors for
DataTypeandBinary*types to ease and simplify data type related (nested) pattern matching.