Description
Currently, `UNION/INTERSECT/EXCEPT` query on incompatible types shows a misleading error message like `unresolved operator Union`. We had better show a more correct message. This will help users in the situation of SPARK-16704
Before
scala> sql("select 1,2,3 union (select 1,array(2),3)") org.apache.spark.sql.AnalysisException: unresolved operator 'Union; scala> sql("select 1,2,3 intersect (select 1,array(2),3)") org.apache.spark.sql.AnalysisException: unresolved operator 'Intersect; scala> sql("select 1,2,3 except (select 1,array(2),3)") org.apache.spark.sql.AnalysisException: unresolved operator 'Except;
After
scala> sql("select 1,2,3 union (select 1,array(2),3)") org.apache.spark.sql.AnalysisException: Union can only be performed on tables with the compatible column types. The first table has `[IntegerType, IntegerType, IntegerType]` and second table has `[IntegerType, ArrayType(IntegerType,false), IntegerType]`. The 2th column is incompatible; scala> sql("select 1,2,3 intersect (select 1,array(2),3)") org.apache.spark.sql.AnalysisException: Intersect can only be performed on tables with the compatible column types. The first table has `[IntegerType, IntegerType, IntegerType]` and second table has `[IntegerType, ArrayType(IntegerType,false), IntegerType]`. The 2th column is incompatible; scala> sql("select 1,2,3 except (select 1,array(2),3)") org.apache.spark.sql.AnalysisException: Except can only be performed on tables with the compatible column types. The first table has `[IntegerType, IntegerType, IntegerType]` and second table has `[IntegerType, ArrayType(IntegerType,false), IntegerType]`. The 2th column is incompatible;