diff options
author | Cheng Lian <lian@databricks.com> | 2015-06-05 23:06:19 +0800 |
---|---|---|
committer | Cheng Lian <lian@databricks.com> | 2015-06-05 23:06:19 +0800 |
commit | bc0d76a246cc534234b96a661d70feb94b26538c (patch) | |
tree | 2f8efcd3f4b773ee64c23ab4fafbaba7878101f0 /R | |
parent | 700312e12f9588f01a592d6eac7bff7eb366ac8f (diff) | |
download | spark-bc0d76a246cc534234b96a661d70feb94b26538c.tar.gz spark-bc0d76a246cc534234b96a661d70feb94b26538c.tar.bz2 spark-bc0d76a246cc534234b96a661d70feb94b26538c.zip |
[SQL] Simplifies binary node pattern matching
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
Diffstat (limited to 'R')
0 files changed, 0 insertions, 0 deletions