You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by dongjoon-hyun <gi...@git.apache.org> on 2016/07/26 00:12:18 UTC

[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve error message for `Uni...

GitHub user dongjoon-hyun opened a pull request:

    https://github.com/apache/spark/pull/14355

    [SPARK-16726][SQL] Improve error message for `Union` queries for incompatible types

    ## What changes were proposed in this pull request?
    
    Currently, `UNION` queries on incompatible types show misleading error messages, i.e., `unresolved operator Union`. We had better show a more correct message.
    
    **Before**
    ```
    scala> sql("select 1 union (select array(1))")
    org.apache.spark.sql.AnalysisException: unresolved operator 'Union;
    ```
    
    **After**
    ```
    scala> sql("select 1 union (select array(1))")
    org.apache.spark.sql.AnalysisException: Unions can only be performed on tables with the compatible column types, but one table has '[IntegerType]' and another table has '[ArrayType(IntegerType,false)]';
    ```
    
    ## How was this patch tested?
    
    Pass the Jenkins test with a new test case.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/dongjoon-hyun/spark SPARK-16726

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/14355.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #14355
    
----
commit 98682a53b28a2848727599f1d06898cd70e8a19e
Author: Dongjoon Hyun <do...@apache.org>
Date:   2016-07-26T00:10:02Z

    [SPARK-16726][SQL] Improve error message for `Union` queries for incompatible types

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Yes, for the compatible types, `Union` works perfectly. :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Hi, @hvanhovell .
    It's updated according to the advice.
    Thank you!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/62850/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Excep...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72452143
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -280,6 +267,37 @@ trait CheckAnalysis extends PredicateHelper {
               case p if p.expressions.exists(PredicateSubquery.hasPredicateSubquery) =>
                 failAnalysis(s"Predicate sub-queries can only be used in a Filter: $p")
     
    +          case _: Union | _: SetOperation =>
    +            if (operator.children.length > 1) {
    --- End diff --
    
    Put the If in the guard.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    LGTM - merging to master. Thanks for working on this!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #63022 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63022/consoleFull)** for PR 14355 at commit [`2b2d59e`](https://github.com/apache/spark/commit/2b2d59e961a178c272e3b118dac5aabbcf92f51c).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Yeah please do! Combining them would be the easiest I suppose.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #62925 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62925/consoleFull)** for PR 14355 at commit [`5fd0948`](https://github.com/apache/spark/commit/5fd0948ef9436d3105cab4817386a1ae53bb4cd5).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Hi, @hvanhovell .
    Could you review this PR? I thought the error message is weird since we support `Union`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63022/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Rebased.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Excep...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72917596
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -280,6 +267,32 @@ trait CheckAnalysis extends PredicateHelper {
               case p if p.expressions.exists(PredicateSubquery.hasPredicateSubquery) =>
                 failAnalysis(s"Predicate sub-queries can only be used in a Filter: $p")
     
    +          case _: Union | _: SetOperation if operator.children.length > 1 =>
    +            def dataTypes(plan: LogicalPlan): Seq[DataType] = plan.output.map(_.dataType)
    +            def ordinalTable(i: Int): String = (if (i == 0) "second" else (i + 2) + "th") + " table"
    +            val ref = dataTypes(operator.children.head)
    +            operator.children.tail.zipWithIndex.foreach { case (child, ti) =>
    +              // Check the number of columns
    +              if (child.output.length != ref.length) {
    +                failAnalysis(
    +                  s"""
    +                    |${operator.nodeName} can only be performed on tables with the same number
    +                    |of columns, but the first table has ${ref.length} columns and
    +                    |the ${ordinalTable(ti)} has ${child.output.length} columns
    +                  """.stripMargin.replace("\n", " ").trim())
    +              }
    +              // Check if the data types match.
    +              dataTypes(child).zip(ref).zipWithIndex.foreach { case ((dt1, dt2), ci) =>
    +                if (dt1 != dt2) {
    +                  failAnalysis(
    +                    s"""
    +                      |${operator.nodeName} can only be performed on tables with the compatible
    +                      |column types. $dt1 <> $dt2 at ${ci + 1}th column of ${ordinalTable(ti)}
    --- End diff --
    
    Oh, I see. Thank you. I'll fix it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Hi, @hvanhovell . The followings are updated.
    
    * Union/Intersect/Except statements are handled.
    * Merge with the previous `case` statement for checking mismatched number of columns.
    * Show the mismatched column number.
    
    The PR and JIRA are updated together.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Excep...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72480617
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -280,6 +267,37 @@ trait CheckAnalysis extends PredicateHelper {
               case p if p.expressions.exists(PredicateSubquery.hasPredicateSubquery) =>
                 failAnalysis(s"Predicate sub-queries can only be used in a Filter: $p")
     
    +          case _: Union | _: SetOperation =>
    +            if (operator.children.length > 1) {
    --- End diff --
    
    Yep.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Thank you, @hvanhovell !


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #63066 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63066/consoleFull)** for PR 14355 at commit [`6b20ffb`](https://github.com/apache/spark/commit/6b20ffb76fa22a81cf16bb51792113f938369534).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Yep. Also, I'll handle INTERSECT and EXCEPT. They have the same issue. Thank you!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/62925/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/62948/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Hi, @hvanhovell . 
    The logic is refactored into a function now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Excep...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72536296
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -280,6 +267,33 @@ trait CheckAnalysis extends PredicateHelper {
               case p if p.expressions.exists(PredicateSubquery.hasPredicateSubquery) =>
                 failAnalysis(s"Predicate sub-queries can only be used in a Filter: $p")
     
    +          case _: Union | _: SetOperation if operator.children.length > 1 =>
    +            def dataTypes(plan: LogicalPlan): Seq[DataType] = plan.output.map(_.dataType)
    +            val ref = dataTypes(operator.children.head)
    +            operator.children.tail.zipWithIndex.foreach { case (child, ti) =>
    +              // Check the number of columns
    +              if (child.output.length != ref.length) {
    +                failAnalysis(
    +                  s"""
    +                    |${operator.nodeName} can only be performed on tables with the same number
    +                    |of columns, but the first table has ${ref.length} columns and
    +                    |the ${if (ti == 0) "second" else (ti + 2) + "th"} table has
    --- End diff --
    
    NIT: You could turn `if (ti == 0) "second" else (ti + 2) + "th"` into a function.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve error message for `Uni...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72391248
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -266,6 +266,13 @@ trait CheckAnalysis extends PredicateHelper {
                     s"but one table has '${firstError.output.length}' columns and another table has " +
                     s"'${s.children.head.output.length}' columns")
     
    +          case Union(c) if c.exists(_.output.map(_.dataType) != c.head.output.map(_.dataType)) =>
    --- End diff --
    
    Should we do the same for the other SET operators?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve error message for `Uni...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72391108
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -266,6 +266,13 @@ trait CheckAnalysis extends PredicateHelper {
                     s"but one table has '${firstError.output.length}' columns and another table has " +
                     s"'${s.children.head.output.length}' columns")
     
    +          case Union(c) if c.exists(_.output.map(_.dataType) != c.head.output.map(_.dataType)) =>
    --- End diff --
    
    This is a bit messy. Can we just move this into the match body and combine it with firstError?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #63022 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63022/consoleFull)** for PR 14355 at commit [`2b2d59e`](https://github.com/apache/spark/commit/2b2d59e961a178c272e3b118dac5aabbcf92f51c).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #62925 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62925/consoleFull)** for PR 14355 at commit [`5fd0948`](https://github.com/apache/spark/commit/5fd0948ef9436d3105cab4817386a1ae53bb4cd5).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Excep...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/14355


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63066/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #62850 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62850/consoleFull)** for PR 14355 at commit [`98682a5`](https://github.com/apache/spark/commit/98682a53b28a2848727599f1d06898cd70e8a19e).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #63066 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63066/consoleFull)** for PR 14355 at commit [`6b20ffb`](https://github.com/apache/spark/commit/6b20ffb76fa22a81cf16bb51792113f938369534).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #62948 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62948/consoleFull)** for PR 14355 at commit [`71e8ec9`](https://github.com/apache/spark/commit/71e8ec90413a58c25bd7b5c612a9821a797652b3).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #62929 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62929/consoleFull)** for PR 14355 at commit [`d2e51f7`](https://github.com/apache/spark/commit/d2e51f76292f562217a23ee48586587a8fced2c1).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    @dongjoon-hyun Do you mind if I ask a question please?
    
    It seems it works in MySQL supports `UNION ALL` for the compatible types, for example, numeric compatible types. If my understanding is correct, it seems it throws an exception when they are any combination of mismatched types. Should this be maybe considered as well?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Excep...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72536913
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -280,6 +267,33 @@ trait CheckAnalysis extends PredicateHelper {
               case p if p.expressions.exists(PredicateSubquery.hasPredicateSubquery) =>
                 failAnalysis(s"Predicate sub-queries can only be used in a Filter: $p")
     
    +          case _: Union | _: SetOperation if operator.children.length > 1 =>
    +            def dataTypes(plan: LogicalPlan): Seq[DataType] = plan.output.map(_.dataType)
    +            val ref = dataTypes(operator.children.head)
    +            operator.children.tail.zipWithIndex.foreach { case (child, ti) =>
    +              // Check the number of columns
    +              if (child.output.length != ref.length) {
    +                failAnalysis(
    +                  s"""
    +                    |${operator.nodeName} can only be performed on tables with the same number
    +                    |of columns, but the first table has ${ref.length} columns and
    +                    |the ${if (ti == 0) "second" else (ti + 2) + "th"} table has
    --- End diff --
    
    Oh, sure. I'll fix soon.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Excep...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72480778
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -280,6 +267,37 @@ trait CheckAnalysis extends PredicateHelper {
               case p if p.expressions.exists(PredicateSubquery.hasPredicateSubquery) =>
                 failAnalysis(s"Predicate sub-queries can only be used in a Filter: $p")
     
    +          case _: Union | _: SetOperation =>
    +            if (operator.children.length > 1) {
    +              val dataTypes = operator.children.head.output.map(_.dataType)
    +              val firstError = operator.children.find(_.output.map(_.dataType) != dataTypes)
    +              if (firstError.isDefined) {
    +                val tableIndex = operator.children.indexOf(firstError.get) + 1
    +                if (dataTypes.length != firstError.get.output.length) {
    +                  failAnalysis(
    +                    s"""
    +                      |${operator.nodeName} can only be performed on tables with the same number
    +                      |of columns, but the first table has ${dataTypes.length} columns and
    +                      |the ${if (tableIndex == 2) "second" else tableIndex + "th"} table has
    +                      |${firstError.get.output.length} columns
    +                    """.stripMargin.replace("\n", " ").trim())
    +                } else {
    +                  val columnIndex = firstError.get.output.map(_.dataType).zipWithIndex.find {
    +                    case (dataType, i) => dataType != dataTypes(i)
    +                  }.get._2 + 1
    +                  failAnalysis(
    +                    s"""
    +                      |${operator.nodeName} can only be performed on tables with the compatible
    +                      |column types. The first table has '[${dataTypes.mkString(", ")}]'
    +                      |and ${if (tableIndex == 2) "second" else tableIndex + "th"} table has
    +                      |'[${firstError.get.output.map(_.dataType).mkString(", ")}]'. The
    +                      |${if (columnIndex == 1) "first" else columnIndex + "th"} column is
    +                      |incompatible
    +                    """.stripMargin.replace("\n", " ").trim())
    +                }
    +              }
    +            }
    +
    --- End diff --
    
    Oh, I see.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #62948 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62948/consoleFull)** for PR 14355 at commit [`71e8ec9`](https://github.com/apache/spark/commit/71e8ec90413a58c25bd7b5c612a9821a797652b3).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Thank you for review, @hvanhovell . I'll update like that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/62929/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Excep...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72452237
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -280,6 +267,37 @@ trait CheckAnalysis extends PredicateHelper {
               case p if p.expressions.exists(PredicateSubquery.hasPredicateSubquery) =>
                 failAnalysis(s"Predicate sub-queries can only be used in a Filter: $p")
     
    +          case _: Union | _: SetOperation =>
    +            if (operator.children.length > 1) {
    +              val dataTypes = operator.children.head.output.map(_.dataType)
    +              val firstError = operator.children.find(_.output.map(_.dataType) != dataTypes)
    +              if (firstError.isDefined) {
    +                val tableIndex = operator.children.indexOf(firstError.get) + 1
    +                if (dataTypes.length != firstError.get.output.length) {
    +                  failAnalysis(
    +                    s"""
    +                      |${operator.nodeName} can only be performed on tables with the same number
    +                      |of columns, but the first table has ${dataTypes.length} columns and
    +                      |the ${if (tableIndex == 2) "second" else tableIndex + "th"} table has
    +                      |${firstError.get.output.length} columns
    +                    """.stripMargin.replace("\n", " ").trim())
    +                } else {
    +                  val columnIndex = firstError.get.output.map(_.dataType).zipWithIndex.find {
    +                    case (dataType, i) => dataType != dataTypes(i)
    +                  }.get._2 + 1
    +                  failAnalysis(
    +                    s"""
    +                      |${operator.nodeName} can only be performed on tables with the compatible
    +                      |column types. The first table has '[${dataTypes.mkString(", ")}]'
    +                      |and ${if (tableIndex == 2) "second" else tableIndex + "th"} table has
    +                      |'[${firstError.get.output.map(_.dataType).mkString(", ")}]'. The
    +                      |${if (columnIndex == 1) "first" else columnIndex + "th"} column is
    +                      |incompatible
    +                    """.stripMargin.replace("\n", " ").trim())
    +                }
    +              }
    +            }
    +
    --- End diff --
    
    I was more thinking of something like this (not checked for syntax):
    ```scala
    def dataTypes(plan: LogicalPlan): Seq[DataType] = plan.output.map(_.dataType)
    val ref = dataTypes(operator.children.head)
    operator.children.tail.foreach { child =>
      // Check the number of columns
      if (children.output.size() != ref.size()) {
        failAnalysis("size")
      }
      // Check if the data types match.
      dataTypes(child).zip(ref).zipWithIndex.foreach { case ((dt1, dt2), index) =>
        if (dt1 != dt2) {
          failAnalysis(s"$dt1 <> $dt2 @ $i")
        }
      }
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Hi, @hvanhovell .
    Could you review this PR again when you have some time?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve error message for `Uni...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72391196
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -266,6 +266,13 @@ trait CheckAnalysis extends PredicateHelper {
                     s"but one table has '${firstError.output.length}' columns and another table has " +
                     s"'${s.children.head.output.length}' columns")
     
    +          case Union(c) if c.exists(_.output.map(_.dataType) != c.head.output.map(_.dataType)) =>
    +            val firstError = c.find(_.output.map(_.dataType) != c.head.output.map(_.dataType)).get
    +            failAnalysis(
    --- End diff --
    
    It would be very useful to know which field(s) are causing trouble. Now I have to scan the list my self.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #62850 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62850/consoleFull)** for PR 14355 at commit [`98682a5`](https://github.com/apache/spark/commit/98682a53b28a2848727599f1d06898cd70e8a19e).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Except` erro...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    **[Test build #62929 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62929/consoleFull)** for PR 14355 at commit [`d2e51f7`](https://github.com/apache/spark/commit/d2e51f76292f562217a23ee48586587a8fced2c1).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark issue #14355: [SPARK-16726][SQL] Improve error message for `Union` que...

Posted by dongjoon-hyun <gi...@git.apache.org>.
Github user dongjoon-hyun commented on the issue:

    https://github.com/apache/spark/pull/14355
  
    Hi, @hvanhovell .
    There is two cases statements including mine (the second one). May I change both? Actually, I followed the style of the previous one.
    ```scala
     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, " +
            s"but one table has '${firstError.output.length}' columns and another table has " +
            s"'${s.children.head.output.length}' columns")
    
    + case Union(c) if c.exists(_.output.map(_.dataType) != c.head.output.map(_.dataType)) =>
    +   val firstError = c.find(_.output.map(_.dataType) != c.head.output.map(_.dataType)).get
    +     failAnalysis(
    +       s"Unions can only be performed on tables with the compatible column types, " +
    +         s"but one table has '[${c.head.output.map(_.dataType).mkString(", ")}]' " +
    +         s"and another table has '[${firstError.output.map(_.dataType).mkString(", ")}]'")
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request #14355: [SPARK-16726][SQL] Improve `Union/Intersect/Excep...

Posted by hvanhovell <gi...@git.apache.org>.
Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14355#discussion_r72912491
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala ---
    @@ -280,6 +267,32 @@ trait CheckAnalysis extends PredicateHelper {
               case p if p.expressions.exists(PredicateSubquery.hasPredicateSubquery) =>
                 failAnalysis(s"Predicate sub-queries can only be used in a Filter: $p")
     
    +          case _: Union | _: SetOperation if operator.children.length > 1 =>
    +            def dataTypes(plan: LogicalPlan): Seq[DataType] = plan.output.map(_.dataType)
    +            def ordinalTable(i: Int): String = (if (i == 0) "second" else (i + 2) + "th") + " table"
    +            val ref = dataTypes(operator.children.head)
    +            operator.children.tail.zipWithIndex.foreach { case (child, ti) =>
    +              // Check the number of columns
    +              if (child.output.length != ref.length) {
    +                failAnalysis(
    +                  s"""
    +                    |${operator.nodeName} can only be performed on tables with the same number
    +                    |of columns, but the first table has ${ref.length} columns and
    +                    |the ${ordinalTable(ti)} has ${child.output.length} columns
    +                  """.stripMargin.replace("\n", " ").trim())
    +              }
    +              // Check if the data types match.
    +              dataTypes(child).zip(ref).zipWithIndex.foreach { case ((dt1, dt2), ci) =>
    +                if (dt1 != dt2) {
    +                  failAnalysis(
    +                    s"""
    +                      |${operator.nodeName} can only be performed on tables with the compatible
    +                      |column types. $dt1 <> $dt2 at ${ci + 1}th column of ${ordinalTable(ti)}
    --- End diff --
    
    NIT:`${ci + th}` can also apply the first/second column. Also `column of` should end with `the`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org