Skip to content

[SPARK-31468][SQL] Null types should be implicitly casted to Decimal types - #28241

Closed
maropu wants to merge 1 commit into
apache:masterfrom
maropu:SPARK-31468
Closed

[SPARK-31468][SQL] Null types should be implicitly casted to Decimal types#28241
maropu wants to merge 1 commit into
apache:masterfrom
maropu:SPARK-31468

Conversation

@maropu

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

This PR intends to fix a bug that occurs when comparing null types to decimal types in master/branch-3.0;

scala> Seq(BigDecimal(10)).toDF("v1").selectExpr("v1 = NULL").explain(true)
org.apache.spark.sql.AnalysisException: cannot resolve '(`v1` = NULL)' due to data type mismatch: differing types in '(`v1` = NULL)' (decimal(38,18) and null).; line 1 pos 0;
'Project [(v1#5 = null) AS (v1 = NULL)#7]
+- Project [value#2 AS v1#5]
+- LocalRelation [value#2]
...

The query above passed in v2.4.5.

Why are the changes needed?

bugfix

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added tests.

@SparkQA

Copy link
Copy Markdown

Test build #121404 has finished for PR 28241 at commit 8b18deb.

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

@maropu

Copy link
Copy Markdown
MemberAuthor

cc: @cloud-fan@viirya

@cloud-fan

Copy link
Copy Markdown
Contributor

good catch! LGTM

@cloud-fan

Copy link
Copy Markdown
Contributor

merging to master/3.0

cloud-fan pushed a commit that referenced this pull request Apr 17, 2020
…types
### What changes were proposed in this pull request?
This PR intends to fix a bug that occurs when comparing null types to decimal types in master/branch-3.0;
```
scala> Seq(BigDecimal(10)).toDF("v1").selectExpr("v1 = NULL").explain(true)
org.apache.spark.sql.AnalysisException: cannot resolve '(`v1` = NULL)' due to data type mismatch: differing types in '(`v1` = NULL)' (decimal(38,18) and null).; line 1 pos 0;
'Project [(v1#5 = null) AS (v1 = NULL)#7]
+- Project [value#2 AS v1#5]
+- LocalRelation [value#2]
...
```
The query above passed in v2.4.5.
### Why are the changes needed?
bugfix
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Added tests.
Closes#28241 from maropu/SPARK-31468.
Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit a7fb330)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@maropu

Copy link
Copy Markdown
MemberAuthor

Thanks for the quick response, @cloud-fan !

@viiryaviirya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM too.

@maropu

Copy link
Copy Markdown
MemberAuthor

Thanks always, @viirya

Sign up for freeto 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.

4 participants

@maropu@SparkQA@cloud-fan@viirya