Skip to content

[SPARK-17108][SQL]: Fix BIGINT and INT comparison failure in spark sql - #15448

Closed
weiqingy wants to merge 3 commits into
apache:masterfrom
weiqingy:SPARK_17108
Closed

[SPARK-17108][SQL]: Fix BIGINT and INT comparison failure in spark sql#15448
weiqingy wants to merge 3 commits into
apache:masterfrom
weiqingy:SPARK_17108

Conversation

@weiqingy

@weiqingyweiqingy commented Oct 12, 2016

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add a function to check if two integers are compatible when invoking acceptsType() in DataType.

How was this patch tested?

Manually.
E.g.

 spark.sql("create table t3(a map<bigint, array<string>>)")
spark.sql("select * from t3 where a[1] is not null")

Before:

cannot resolve 't.`a`[1]' due to data type mismatch: argument 2 requires bigint type, however, '1' is of int type.; line 1 pos 22
org.apache.spark.sql.AnalysisException: cannot resolve 't.`a`[1]' due to data type mismatch: argument 2 requires bigint type, however, '1' is of int type.; line 1 pos 22
at org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42)
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:82)
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:74)
at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformUp$1.apply(TreeNode.scala:307)

After:
Run the sql queries above. No errors.

@hvanhovell

Copy link
Copy Markdown
Contributor

Could you try to fix this by adding implicit casting to the GetMapValue (make it extend ImplicitCastInputTypes instead of ExpectsInputTypes)?

@hvanhovell

hvanhovell commented Oct 12, 2016

Copy link
Copy Markdown
Contributor

Also add a unit test please.

@SparkQA

Copy link
Copy Markdown

Test build #3330 has finished for PR 15448 at commit ec3d552.

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

@weiqingy

Copy link
Copy Markdown
ContributorAuthor

Hi, @hvanhovell Thanks for the quick feedback. Yes, I will update the PR.

@weiqingy

Copy link
Copy Markdown
ContributorAuthor

Hi, @hvanhovell I have updated the PR, could you help review it again?

@weiqingy

Copy link
Copy Markdown
ContributorAuthor

Hi, @hvanhovell Could you review this PR again? Thanks.

1 similar comment
@weiqingy

Copy link
Copy Markdown
ContributorAuthor

Hi, @hvanhovell Could you review this PR again? Thanks.

@hvanhovell

Copy link
Copy Markdown
Contributor

LGTM. Merging to master/2.1. Thanks!

My apologies for the long wait!

asfgit pushed a commit that referenced this pull request Nov 7, 2016
## What changes were proposed in this pull request?
Add a function to check if two integers are compatible when invoking `acceptsType()` in `DataType`.
## How was this patch tested?
Manually.
E.g.
```
spark.sql("create table t3(a map<bigint, array<string>>)")
spark.sql("select * from t3 where a[1] is not null")
```
Before:
```
cannot resolve 't.`a`[1]' due to data type mismatch: argument 2 requires bigint type, however, '1' is of int type.; line 1 pos 22
org.apache.spark.sql.AnalysisException: cannot resolve 't.`a`[1]' due to data type mismatch: argument 2 requires bigint type, however, '1' is of int type.; line 1 pos 22
at org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42)
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:82)
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:74)
at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformUp$1.apply(TreeNode.scala:307)
```
After:
Run the sql queries above. No errors.
Author: Weiqing Yang <yangweiqing001@gmail.com>
Closes#15448 from weiqingy/SPARK_17108.
(cherry picked from commit 0d95662)
Signed-off-by: Herman van Hovell <hvanhovell@databricks.com>
@asfgitasfgit closed this in 0d95662Nov 7, 2016
@weiqingy

Copy link
Copy Markdown
ContributorAuthor

@hvanhovell Thanks for the review!

zzcclp added a commit to zzcclp/spark that referenced this pull request Nov 15, 2016
uzadude pushed a commit to uzadude/spark that referenced this pull request Jan 27, 2017
## What changes were proposed in this pull request?
Add a function to check if two integers are compatible when invoking `acceptsType()` in `DataType`.
## How was this patch tested?
Manually.
E.g.
```
spark.sql("create table t3(a map<bigint, array<string>>)")
spark.sql("select * from t3 where a[1] is not null")
```
Before:
```
cannot resolve 't.`a`[1]' due to data type mismatch: argument 2 requires bigint type, however, '1' is of int type.; line 1 pos 22
org.apache.spark.sql.AnalysisException: cannot resolve 't.`a`[1]' due to data type mismatch: argument 2 requires bigint type, however, '1' is of int type.; line 1 pos 22
at org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42)
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:82)
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:74)
at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformUp$1.apply(TreeNode.scala:307)
```
After:
Run the sql queries above. No errors.
Author: Weiqing Yang <yangweiqing001@gmail.com>
Closesapache#15448 from weiqingy/SPARK_17108.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@weiqingy@hvanhovell@SparkQA