Repository: spark
Updated Branches:
  refs/heads/branch-2.0 0ecc105d2 -> a675f5e1d


[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 <[email protected]>

Closes #13043 from dongjoon-hyun/SPARK-15265.

(cherry picked from commit 66554596064303757b921ebef683c3506d749775)
Signed-off-by: Reynold Xin <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/a675f5e1
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/a675f5e1
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/a675f5e1

Branch: refs/heads/branch-2.0
Commit: a675f5e1d6653f06e34da34843b0ac0dc226bb04
Parents: 0ecc105
Author: Dongjoon Hyun <[email protected]>
Authored: Tue May 10 22:27:22 2016 -0700
Committer: Reynold Xin <[email protected]>
Committed: Tue May 10 22:27:29 2016 -0700

----------------------------------------------------------------------
 .../spark/sql/catalyst/analysis/CheckAnalysis.scala      | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/a675f5e1/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
----------------------------------------------------------------------
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 74197c4..28aa249 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 {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to