You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/04/20 15:08:31 UTC

[GitHub] [spark] gengliangwang opened a new pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

gengliangwang opened a new pull request #32260:
URL: https://github.com/apache/spark/pull/32260


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   IntegralDivide should throw an exception on overflow in ANSI mode.
   There is only one case that can cause that:
   ```
   Long.MinValue div -1
   ```
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   ANSI compliance 
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   Yes, IntegralDivide throws an exception on overflow in ANSI mode
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   Unit test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823442757


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/42222/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823403103


   **[Test build #137695 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137695/testReport)** for PR 32260 at commit [`d91fa4e`](https://github.com/apache/spark/commit/d91fa4e0a77210534cbf7d29ac206e16c83ed0e5).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32260:
URL: https://github.com/apache/spark/pull/32260#discussion_r616786590



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -562,13 +577,27 @@ case class IntegralDivide(
       case d: DecimalType =>
         d.asIntegral.asInstanceOf[Integral[Any]]
     }
-    (x, y) => {
-      val res = integral.quot(x, y)
-      if (res == null) {
-        null
-      } else {
-        integral.asInstanceOf[Integral[Any]].toLong(res)
+    val _div =
+      (x: Any, y: Any) => {
+        val res = integral.quot(x, y)
+        if (res == null) {
+          null
+        } else {
+          integral.asInstanceOf[Integral[Any]].toLong(res)
+        }
       }
+
+    dataType match {
+      case LongType if failOnError =>

Review comment:
       This is not necessary because this class has `override def dataType: DataType = LongType`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] arvindsaik commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
arvindsaik commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823512184


   Have we considered returning `NULL` in the non-ANSI mode instead of `Long.MinValue`?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823410583


   **[Test build #137696 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137696/testReport)** for PR 32260 at commit [`9ade940`](https://github.com/apache/spark/commit/9ade94024d1386b0e850aa2d098fd0c48e7ae83a).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823401471






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823438022


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/42222/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823563565


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137695/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823598378


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137696/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823401471






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823607395


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137697/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32260:
URL: https://github.com/apache/spark/pull/32260#discussion_r616839630



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -562,13 +577,27 @@ case class IntegralDivide(
       case d: DecimalType =>
         d.asIntegral.asInstanceOf[Integral[Any]]
     }
-    (x, y) => {
-      val res = integral.quot(x, y)
-      if (res == null) {
-        null
-      } else {
-        integral.asInstanceOf[Integral[Any]].toLong(res)
+    val _div =
+      (x: Any, y: Any) => {
+        val res = integral.quot(x, y)
+        if (res == null) {
+          null
+        } else {
+          integral.asInstanceOf[Integral[Any]].toLong(res)
+        }
       }
+
+    dataType match {
+      case LongType if failOnError =>
+        (x: Any, y: Any) => {
+          if (x == Long.MinValue && y == -1) {

Review comment:
       yea, similar to the codegen path we can use `if (isIntegralDivide)`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823392826






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823447722






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32260:
URL: https://github.com/apache/spark/pull/32260#discussion_r617267545



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -404,6 +404,9 @@ trait DivModLike extends BinaryArithmetic {
 
   protected def decimalToDataTypeCodeGen(decimalResult: String): String = decimalResult
 
+  // Whether we should check overflow or not in ANSI mode.
+  protected def checkDivideOverflow: Boolean = false

Review comment:
       Is this simply `left.dataType == LongType`? For `Divide`, the child is either double or decimal, so won't hit this branch.
   
   Under the hood, what we really want to handle is `Long.MinValue / -1`, so check `left.dataType == LongType` looks reasonable.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] gengliangwang commented on a change in pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on a change in pull request #32260:
URL: https://github.com/apache/spark/pull/32260#discussion_r616821690



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -562,13 +577,27 @@ case class IntegralDivide(
       case d: DecimalType =>
         d.asIntegral.asInstanceOf[Integral[Any]]
     }
-    (x, y) => {
-      val res = integral.quot(x, y)
-      if (res == null) {
-        null
-      } else {
-        integral.asInstanceOf[Integral[Any]].toLong(res)
+    val _div =
+      (x: Any, y: Any) => {
+        val res = integral.quot(x, y)
+        if (res == null) {
+          null
+        } else {
+          integral.asInstanceOf[Integral[Any]].toLong(res)
+        }
       }
+
+    dataType match {
+      case LongType if failOnError =>
+        (x: Any, y: Any) => {
+          if (x == Long.MinValue && y == -1) {

Review comment:
       This is not happening in Divide or Mod




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823480013






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823410583


   **[Test build #137696 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137696/testReport)** for PR 32260 at commit [`9ade940`](https://github.com/apache/spark/commit/9ade94024d1386b0e850aa2d098fd0c48e7ae83a).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823606444


   **[Test build #137697 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137697/testReport)** for PR 32260 at commit [`64f1431`](https://github.com/apache/spark/commit/64f1431195e666227094a456f9c4d20fff181004).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823403103


   **[Test build #137695 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137695/testReport)** for PR 32260 at commit [`d91fa4e`](https://github.com/apache/spark/commit/d91fa4e0a77210534cbf7d29ac206e16c83ed0e5).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] gengliangwang commented on a change in pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on a change in pull request #32260:
URL: https://github.com/apache/spark/pull/32260#discussion_r616845726



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -562,13 +577,27 @@ case class IntegralDivide(
       case d: DecimalType =>
         d.asIntegral.asInstanceOf[Integral[Any]]
     }
-    (x, y) => {
-      val res = integral.quot(x, y)
-      if (res == null) {
-        null
-      } else {
-        integral.asInstanceOf[Integral[Any]].toLong(res)
+    val _div =
+      (x: Any, y: Any) => {
+        val res = integral.quot(x, y)
+        if (res == null) {
+          null
+        } else {
+          integral.asInstanceOf[Integral[Any]].toLong(res)
+        }
       }
+
+    dataType match {
+      case LongType if failOnError =>
+        (x: Any, y: Any) => {
+          if (x == Long.MinValue && y == -1) {

Review comment:
       Yeah it's tricky. It is hard to reuse the`doGenCode` here so I added a new flag `isIntegralDivide`. 
   The original idea is to keep the special handling code in `IntegralDivide` if possible.
   But now it seems asymmetric in both sides..
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] gengliangwang commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823815529


   @arvindsaik I think we can make it in safe version functions:
   https://issues.apache.org/jira/browse/SPARK-35161


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32260:
URL: https://github.com/apache/spark/pull/32260#discussion_r616788886



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -562,13 +577,27 @@ case class IntegralDivide(
       case d: DecimalType =>
         d.asIntegral.asInstanceOf[Integral[Any]]
     }
-    (x, y) => {
-      val res = integral.quot(x, y)
-      if (res == null) {
-        null
-      } else {
-        integral.asInstanceOf[Integral[Any]].toLong(res)
+    val _div =
+      (x: Any, y: Any) => {
+        val res = integral.quot(x, y)
+        if (res == null) {
+          null
+        } else {
+          integral.asInstanceOf[Integral[Any]].toLong(res)
+        }
       }
+
+    dataType match {
+      case LongType if failOnError =>
+        (x: Any, y: Any) => {
+          if (x == Long.MinValue && y == -1) {

Review comment:
       Shall we do this in `DivModLike.eval`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823487329


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/42224/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] gengliangwang commented on a change in pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on a change in pull request #32260:
URL: https://github.com/apache/spark/pull/32260#discussion_r616821039



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -562,13 +577,27 @@ case class IntegralDivide(
       case d: DecimalType =>
         d.asIntegral.asInstanceOf[Integral[Any]]
     }
-    (x, y) => {
-      val res = integral.quot(x, y)
-      if (res == null) {
-        null
-      } else {
-        integral.asInstanceOf[Integral[Any]].toLong(res)
+    val _div =
+      (x: Any, y: Any) => {
+        val res = integral.quot(x, y)
+        if (res == null) {
+          null
+        } else {
+          integral.asInstanceOf[Integral[Any]].toLong(res)
+        }
       }
+
+    dataType match {
+      case LongType if failOnError =>

Review comment:
       Yeah you are right




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823591112


   **[Test build #137696 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137696/testReport)** for PR 32260 at commit [`9ade940`](https://github.com/apache/spark/commit/9ade94024d1386b0e850aa2d098fd0c48e7ae83a).
    * This patch passes all tests.
    * This patch merges cleanly.
    * This patch adds no public classes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] gengliangwang closed pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
gengliangwang closed pull request #32260:
URL: https://github.com/apache/spark/pull/32260


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823447722






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823607395


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137697/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823449102


   **[Test build #137697 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137697/testReport)** for PR 32260 at commit [`64f1431`](https://github.com/apache/spark/commit/64f1431195e666227094a456f9c4d20fff181004).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823371484


   **[Test build #137692 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137692/testReport)** for PR 32260 at commit [`1658f5b`](https://github.com/apache/spark/commit/1658f5bf127cd58a68ae9d16250cc11aaaf64ed8).
    * This patch **fails Spark unit tests**.
    * This patch merges cleanly.
    * This patch adds no public classes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823353797


   **[Test build #137692 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137692/testReport)** for PR 32260 at commit [`1658f5b`](https://github.com/apache/spark/commit/1658f5bf127cd58a68ae9d16250cc11aaaf64ed8).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823487329


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/42224/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32260:
URL: https://github.com/apache/spark/pull/32260#discussion_r616786893



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -562,13 +577,27 @@ case class IntegralDivide(
       case d: DecimalType =>
         d.asIntegral.asInstanceOf[Integral[Any]]
     }
-    (x, y) => {
-      val res = integral.quot(x, y)
-      if (res == null) {
-        null
-      } else {
-        integral.asInstanceOf[Integral[Any]].toLong(res)
+    val _div =
+      (x: Any, y: Any) => {
+        val res = integral.quot(x, y)
+        if (res == null) {
+          null
+        } else {
+          integral.asInstanceOf[Integral[Any]].toLong(res)
+        }
       }
+
+    dataType match {
+      case LongType if failOnError =>

Review comment:
       I think we need to check `child.dataType`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA removed a comment on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823353797


   **[Test build #137692 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137692/testReport)** for PR 32260 at commit [`1658f5b`](https://github.com/apache/spark/commit/1658f5bf127cd58a68ae9d16250cc11aaaf64ed8).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] cloud-fan commented on a change in pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #32260:
URL: https://github.com/apache/spark/pull/32260#discussion_r616786893



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -562,13 +577,27 @@ case class IntegralDivide(
       case d: DecimalType =>
         d.asIntegral.asInstanceOf[Integral[Any]]
     }
-    (x, y) => {
-      val res = integral.quot(x, y)
-      if (res == null) {
-        null
-      } else {
-        integral.asInstanceOf[Integral[Any]].toLong(res)
+    val _div =
+      (x: Any, y: Any) => {
+        val res = integral.quot(x, y)
+        if (res == null) {
+          null
+        } else {
+          integral.asInstanceOf[Integral[Any]].toLong(res)
+        }
       }
+
+    dataType match {
+      case LongType if failOnError =>

Review comment:
       I think we need to check `left.dataType`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823449102


   **[Test build #137697 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137697/testReport)** for PR 32260 at commit [`64f1431`](https://github.com/apache/spark/commit/64f1431195e666227094a456f9c4d20fff181004).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823563565


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137695/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] gengliangwang commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823867541


   Merging to master


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823556690


   **[Test build #137695 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/137695/testReport)** for PR 32260 at commit [`d91fa4e`](https://github.com/apache/spark/commit/d91fa4e0a77210534cbf7d29ac206e16c83ed0e5).
    * This patch **fails Spark unit tests**.
    * This patch merges cleanly.
    * This patch adds no public classes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] AmplabJenkins removed a comment on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823598378


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/137696/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] SparkQA commented on pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #32260:
URL: https://github.com/apache/spark/pull/32260#issuecomment-823444220






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [spark] gengliangwang commented on a change in pull request #32260: [SPARK-35152][SQL] ANSI mode: IntegralDivide throws exception on overflow

Posted by GitBox <gi...@apache.org>.
gengliangwang commented on a change in pull request #32260:
URL: https://github.com/apache/spark/pull/32260#discussion_r617273921



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -404,6 +404,9 @@ trait DivModLike extends BinaryArithmetic {
 
   protected def decimalToDataTypeCodeGen(decimalResult: String): String = decimalResult
 
+  // Whether we should check overflow or not in ANSI mode.
+  protected def checkDivideOverflow: Boolean = false

Review comment:
       No, Remainder's left can be Long as well




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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