diff options
author | Dongjoon Hyun <dongjoon@apache.org> | 2016-05-10 22:27:22 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2016-05-10 22:27:22 -0700 |
commit | 66554596064303757b921ebef683c3506d749775 (patch) | |
tree | 753cdbae206e52018be45c0f4fe13aa0a0443131 /sql/catalyst | |
parent | 3ff012051f5bb433abb868e590e59dea18867cd8 (diff) | |
download | spark-66554596064303757b921ebef683c3506d749775.tar.gz spark-66554596064303757b921ebef683c3506d749775.tar.bz2 spark-66554596064303757b921ebef683c3506d749775.zip |
[SPARK-15265][SQL][MINOR] Fix Union query error message indentation
## What changes were proposed in this pull request?
This issue fixes the error message indentation consistently with other set queries (EXCEPT/INTERSECT).
**Before (4 lines)**
```
scala> sql("(select 1) union (select 1, 2)").head
org.apache.spark.sql.AnalysisException:
Unions can only be performed on tables with the same number of columns,
but one table has '2' columns and another table has
'1' columns;
```
**After (one-line)**
```
scala> sql("(select 1) union (select 1, 2)").head
org.apache.spark.sql.AnalysisException: Unions can only be performed on tables with the same number of columns, but one table has '2' columns and another table has '1' columns;
```
**Reference (EXCEPT / INTERSECT)**
```
scala> sql("(select 1) intersect (select 1, 2)").head
org.apache.spark.sql.AnalysisException: Intersect can only be performed on tables with the same number of columns, but the left table has 1 columns and the right has 2;
```
## How was this patch tested?
Manual.
Author: Dongjoon Hyun <dongjoon@apache.org>
Closes #13043 from dongjoon-hyun/SPARK-15265.
Diffstat (limited to 'sql/catalyst')
-rw-r--r-- | sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala index 74197c4653..28aa249888 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala @@ -241,16 +241,15 @@ trait CheckAnalysis extends PredicateHelper { case s @ SetOperation(left, right) if left.output.length != right.output.length => failAnalysis( s"${s.nodeName} can only be performed on tables with the same number of columns, " + - s"but the left table has ${left.output.length} columns and the right has " + - s"${right.output.length}") + s"but the left table has ${left.output.length} columns and the right has " + + s"${right.output.length}") case s: Union if s.children.exists(_.output.length != s.children.head.output.length) => val firstError = s.children.find(_.output.length != s.children.head.output.length).get failAnalysis( - s""" - |Unions can only be performed on tables with the same number of columns, - | but one table has '${firstError.output.length}' columns and another table has - | '${s.children.head.output.length}' columns""".stripMargin) + s"Unions can only be performed on tables with the same number of columns, " + + s"but one table has '${firstError.output.length}' columns and another table has " + + s"'${s.children.head.output.length}' columns") case p if p.expressions.exists(ScalarSubquery.hasCorrelatedScalarSubquery) => p match { |