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

[GitHub] spark pull request #14358: [SPARK-16729][SQL] Throw analysis exception for i...

GitHub user petermaxlee opened a pull request:

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

    [SPARK-16729][SQL] Throw analysis exception for invalid date casts

    ## What changes were proposed in this pull request?
    Spark currently throws exceptions for invalid casts for all other data types except date type. Somehow date type returns null. It should be consistent and throws analysis exception as well.
    
    ## How was this patch tested?
    Added a unit test case in CastSuite.

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

    $ git pull https://github.com/petermaxlee/spark SPARK-16729

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

    https://github.com/apache/spark/pull/14358.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 #14358
    
----
commit 5419b859a7c8669122e8c65e88029a47556c36ee
Author: petermaxlee <pe...@gmail.com>
Date:   2016-07-26T02:13:30Z

    [SPARK-16729][SQL] Spark should throw analysis exception for invalid casts to date type

----


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    I would consider this a bug and put it in branch-2.0. I'm going to cherry pick.



---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/62910/
    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 #14358: [SPARK-16729][SQL] Throw analysis exception for i...

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

    https://github.com/apache/spark/pull/14358#discussion_r72380761
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala ---
    @@ -54,7 +54,9 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
         // follow [[org.apache.spark.sql.catalyst.expressions.Cast.canCast]] logic
         // to ensure we test every possible cast situation here
         atomicTypes.zip(atomicTypes).foreach { case (from, to) =>
    -      checkNullCast(from, to)
    +      if (Cast.canCast(from, to)) {
    --- End diff --
    
    removed


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    @cloud-fan can you take a look?


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for i...

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

    https://github.com/apache/spark/pull/14358#discussion_r72192084
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -228,18 +229,12 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w
           // throw valid precision more than seconds, according to Hive.
           // Timestamp.nanos is in 0 to 999,999,999, no more than a second.
           buildCast[Long](_, t => DateTimeUtils.millisToDays(t / 1000L))
    -    // Hive throws this exception as a Semantic Exception
    -    // It is never possible to compare result when hive return with exception,
    -    // so we can return null
    -    // NULL is more reasonable here, since the query itself obeys the grammar.
    -    case _ => _ => null
    --- End diff --
    
    cc @yhuai @liancheng  , do you remember why we have this behaviour at the beginning?


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for i...

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

    https://github.com/apache/spark/pull/14358#discussion_r72380321
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala ---
    @@ -54,7 +54,9 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
         // follow [[org.apache.spark.sql.catalyst.expressions.Cast.canCast]] logic
         // to ensure we test every possible cast situation here
         atomicTypes.zip(atomicTypes).foreach { case (from, to) =>
    -      checkNullCast(from, to)
    +      if (Cast.canCast(from, to)) {
    --- End diff --
    
    ```
    def canCast(from: DataType, to: DataType): Boolean = (from, to) match {
      case (fromType, toType) if fromType == toType => true
      ......
    ```


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    **[Test build #62857 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62857/consoleFull)** for PR 14358 at commit [`5419b85`](https://github.com/apache/spark/commit/5419b859a7c8669122e8c65e88029a47556c36ee).
     * 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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    thanks, merging to master!


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    Is this good to merge?



---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    LGTM, pending jenkins.


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    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 #14358: [SPARK-16729][SQL] Throw analysis exception for i...

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

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


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    **[Test build #62857 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62857/consoleFull)** for PR 14358 at commit [`5419b85`](https://github.com/apache/spark/commit/5419b859a7c8669122e8c65e88029a47556c36ee).


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for i...

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

    https://github.com/apache/spark/pull/14358#discussion_r72380199
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala ---
    @@ -54,7 +54,9 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
         // follow [[org.apache.spark.sql.catalyst.expressions.Cast.canCast]] logic
         // to ensure we test every possible cast situation here
         atomicTypes.zip(atomicTypes).foreach { case (from, to) =>
    -      checkNullCast(from, to)
    +      if (Cast.canCast(from, to)) {
    --- End diff --
    
    Not all atomicTypes can cast from each other? E.g. date.



---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for i...

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

    https://github.com/apache/spark/pull/14358#discussion_r72380667
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala ---
    @@ -54,7 +54,9 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
         // follow [[org.apache.spark.sql.catalyst.expressions.Cast.canCast]] logic
         // to ensure we test every possible cast situation here
         atomicTypes.zip(atomicTypes).foreach { case (from, to) =>
    -      checkNullCast(from, to)
    +      if (Cast.canCast(from, to)) {
    --- End diff --
    
    ah this is doing self casting - i read it wrong. let me remove 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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    **[Test build #62910 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62910/consoleFull)** for PR 14358 at commit [`0161896`](https://github.com/apache/spark/commit/016189620d711f8e8abb0b2886b9b35ac1321911).
     * 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 pull request #14358: [SPARK-16729][SQL] Throw analysis exception for i...

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

    https://github.com/apache/spark/pull/14358#discussion_r72379875
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala ---
    @@ -54,7 +54,9 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
         // follow [[org.apache.spark.sql.catalyst.expressions.Cast.canCast]] logic
         // to ensure we test every possible cast situation here
         atomicTypes.zip(atomicTypes).foreach { case (from, to) =>
    -      checkNullCast(from, to)
    +      if (Cast.canCast(from, to)) {
    --- End diff --
    
    why this check? doesn;t `from` always equal to `to` here?


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/62857/
    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 #14358: [SPARK-16729][SQL] Throw analysis exception for invalid ...

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

    https://github.com/apache/spark/pull/14358
  
    **[Test build #62910 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62910/consoleFull)** for PR 14358 at commit [`0161896`](https://github.com/apache/spark/commit/016189620d711f8e8abb0b2886b9b35ac1321911).


---
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 #14358: [SPARK-16729][SQL] Throw analysis exception for i...

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

    https://github.com/apache/spark/pull/14358#discussion_r72243943
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala ---
    @@ -228,18 +229,12 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w
           // throw valid precision more than seconds, according to Hive.
           // Timestamp.nanos is in 0 to 999,999,999, no more than a second.
           buildCast[Long](_, t => DateTimeUtils.millisToDays(t / 1000L))
    -    // Hive throws this exception as a Semantic Exception
    -    // It is never possible to compare result when hive return with exception,
    -    // so we can return null
    -    // NULL is more reasonable here, since the query itself obeys the grammar.
    -    case _ => _ => null
    --- End diff --
    
    Seems like a design decision made in the original PR. See here: https://github.com/apache/spark/pull/2344/files#diff-258b71121d8d168e4d53cb5b6dc53ffeR166
    
    I don't think we've ever discussed this case explicitly. This change seems reasonable to me.


---
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