aboutsummaryrefslogtreecommitdiff
path: root/sql/hive
diff options
context:
space:
mode:
authorWeiqing Yang <yangweiqing001@gmail.com>2016-11-07 21:33:01 +0100
committerHerman van Hovell <hvanhovell@databricks.com>2016-11-07 21:33:01 +0100
commit0d95662e7fff26669d4f70e88fdac7a4128a4f49 (patch)
treed3873bb76738f3093058a56a7a02d6201fa7a234 /sql/hive
parentb06c23db9aedae48c9eba9d702ae82fa5647cfe5 (diff)
downloadspark-0d95662e7fff26669d4f70e88fdac7a4128a4f49.tar.gz
spark-0d95662e7fff26669d4f70e88fdac7a4128a4f49.tar.bz2
spark-0d95662e7fff26669d4f70e88fdac7a4128a4f49.zip
[SPARK-17108][SQL] Fix BIGINT and INT comparison failure in spark sql
## 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.
Diffstat (limited to 'sql/hive')
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
index 5e08ef3112..c21db3595f 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
@@ -1939,6 +1939,18 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
}
}
+
+ test("SPARK-17108: Fix BIGINT and INT comparison failure in spark sql") {
+ sql("create table t1(a map<bigint, array<string>>)")
+ sql("select * from t1 where a[1] is not null")
+
+ sql("create table t2(a map<int, array<string>>)")
+ sql("select * from t2 where a[1] is not null")
+
+ sql("create table t3(a map<bigint, array<string>>)")
+ sql("select * from t3 where a[1L] is not null")
+ }
+
test("SPARK-17796 Support wildcard character in filename for LOAD DATA LOCAL INPATH") {
withTempDir { dir =>
for (i <- 1 to 3) {