Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-28201][SQL] Revisit MakeDecimal behavior on overflow #25010

Closed
wants to merge 5 commits into from

Conversation

mgaido91
Copy link
Contributor

@mgaido91 mgaido91 commented Jun 29, 2019

What changes were proposed in this pull request?

In SPARK-23179, it has been introduced a flag to control the behavior in case of overflow on decimals. The behavior is: returning null when spark.sql.decimalOperations.nullOnOverflow (default and traditional Spark behavior); throwing an ArithmeticException if that conf is false (according to SQL standards, other DBs behavior).

MakeDecimal so far had an ambiguous behavior. In case of codegen mode, it returned null as the other operators, but in interpreted mode, it was throwing an IllegalArgumentException.

The PR aligns MakeDecimal's behavior with the one of other operators as defined in SPARK-23179. So now both modes return null or throw ArithmeticException according to spark.sql.decimalOperations.nullOnOverflow's value.

Credits for this PR to @mickjermsurawong-stripe who pointed out the wrong behavior in #20350.

How was this patch tested?

improved UTs

@mgaido91
Copy link
Contributor Author

mgaido91 commented Jun 29, 2019

@SparkQA
Copy link

SparkQA commented Jun 29, 2019

Test build #107036 has finished for PR 25010 at commit ee953d2.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

@JoshRosen JoshRosen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting a patch so quickly! The changes here look pretty straightforward.

I left two review questions, mostly asking about whether certain optimizations are necessary (or whether they can be skipped to improve code readability).

I'd also appreciate a second review from someone else who's also familiar with Decimals and codegen. (/cc @cloud-fan, who reviewed #20350)

@SparkQA
Copy link

SparkQA commented Jun 29, 2019

Test build #107042 has finished for PR 25010 at commit 90b0fd2.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jun 29, 2019

Test build #107044 has finished for PR 25010 at commit 4928330.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in bc4a676 Jul 1, 2019
@mickjermsurawong-stripe
Copy link
Contributor

hi @mgaido91, I made one follow-up here. Seems like aggregation path still can have null output even with throwing exception flag on. https://issues.apache.org/jira/browse/SPARK-28224

s"Decimal precision ${decimalVal.precision} exceeds max precision $precision")
if (decimalVal.precision > precision) {
throw new ArithmeticException(
s"Decimal precision ${decimalVal.precision} exceeds max precision $precision")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, All.
This seems to break JDBC Integration Test suite. I'll make a followup PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made #25165 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dongjoon-hyun , sorry for the trouble. I hadn't run integration tests indeed.

vinodkc pushed a commit to vinodkc/spark that referenced this pull request Jul 18, 2019
…ng to the new exception message

## What changes were proposed in this pull request?

apache#25010 breaks the integration test suite due to the changing the user-facing exception like the following. This PR fixes the integration test suite.

```scala
-    require(
-      decimalVal.precision <= precision,
-      s"Decimal precision ${decimalVal.precision} exceeds max precision $precision")
+    if (decimalVal.precision > precision) {
+      throw new ArithmeticException(
+        s"Decimal precision ${decimalVal.precision} exceeds max precision $precision")
+    }
```

## How was this patch tested?

Manual test.
```
$ build/mvn install -DskipTests
$ build/mvn -Pdocker-integration-tests -pl :spark-docker-integration-tests_2.12 test
```

Closes apache#25165 from dongjoon-hyun/SPARK-28201.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants