Skip to content

Conversation

@weiqingy
Copy link
Contributor

@weiqingy weiqingy commented Oct 12, 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.

@hvanhovell
Copy link
Contributor

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

@hvanhovell
Copy link
Contributor

hvanhovell commented Oct 12, 2016

Also add a unit test please.

@SparkQA
Copy link

SparkQA commented Oct 12, 2016

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

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

@weiqingy
Copy link
Contributor Author

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

@weiqingy
Copy link
Contributor Author

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

1 similar comment
@weiqingy
Copy link
Contributor Author

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

@hvanhovell
Copy link
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 <[email protected]>

Closes #15448 from weiqingy/SPARK_17108.

(cherry picked from commit 0d95662)
Signed-off-by: Herman van Hovell <[email protected]>
@asfgit asfgit closed this in 0d95662 Nov 7, 2016
@weiqingy
Copy link
Contributor Author

weiqingy commented Nov 7, 2016

@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 <[email protected]>

Closes apache#15448 from weiqingy/SPARK_17108.
Sign up for free to 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