Repository: spark
Updated Branches:
  refs/heads/master 703c42c39 -> 58c9e6e77


[SPARK-20145] Fix range case insensitive bug in SQL

## What changes were proposed in this pull request?
Range in SQL should be case insensitive

## How was this patch tested?
unit test

Author: samelamin <hussam.ela...@gmail.com>
Author: samelamin <sam_ela...@discovery.com>

Closes #17487 from samelamin/SPARK-20145.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/58c9e6e7
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/58c9e6e7
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/58c9e6e7

Branch: refs/heads/master
Commit: 58c9e6e77ae26345291dd9fce2c57aadcc36f66c
Parents: 703c42c
Author: samelamin <hussam.ela...@gmail.com>
Authored: Mon Apr 3 17:16:31 2017 -0700
Committer: Reynold Xin <r...@databricks.com>
Committed: Mon Apr 3 17:16:31 2017 -0700

----------------------------------------------------------------------
 .../analysis/ResolveTableValuedFunctions.scala  |  4 +---
 .../sql-tests/inputs/table-valued-functions.sql |  6 ++++++
 .../results/table-valued-functions.sql.out      | 20 +++++++++++++++++++-
 3 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/58c9e6e7/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTableValuedFunctions.scala
----------------------------------------------------------------------
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTableValuedFunctions.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTableValuedFunctions.scala
index 6b3bb68..8841309 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTableValuedFunctions.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTableValuedFunctions.scala
@@ -17,9 +17,7 @@
 
 package org.apache.spark.sql.catalyst.analysis
 
-import org.apache.spark.{SparkConf, SparkContext}
 import org.apache.spark.sql.catalyst.expressions.Expression
-import org.apache.spark.sql.catalyst.plans._
 import org.apache.spark.sql.catalyst.plans.logical.{LogicalPlan, Range}
 import org.apache.spark.sql.catalyst.rules._
 import org.apache.spark.sql.types.{DataType, IntegerType, LongType}
@@ -105,7 +103,7 @@ object ResolveTableValuedFunctions extends 
Rule[LogicalPlan] {
 
   override def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
     case u: UnresolvedTableValuedFunction if u.functionArgs.forall(_.resolved) 
=>
-      builtinFunctions.get(u.functionName) match {
+      builtinFunctions.get(u.functionName.toLowerCase()) match {
         case Some(tvf) =>
           val resolved = tvf.flatMap { case (argList, resolver) =>
             argList.implicitCast(u.functionArgs) match {

http://git-wip-us.apache.org/repos/asf/spark/blob/58c9e6e7/sql/core/src/test/resources/sql-tests/inputs/table-valued-functions.sql
----------------------------------------------------------------------
diff --git 
a/sql/core/src/test/resources/sql-tests/inputs/table-valued-functions.sql 
b/sql/core/src/test/resources/sql-tests/inputs/table-valued-functions.sql
index 2e6dcd5..d0d2df7 100644
--- a/sql/core/src/test/resources/sql-tests/inputs/table-valued-functions.sql
+++ b/sql/core/src/test/resources/sql-tests/inputs/table-valued-functions.sql
@@ -18,3 +18,9 @@ select * from range(1, 1, 1, 1, 1);
 
 -- range call with null
 select * from range(1, null);
+
+-- range call with a mixed-case function name
+select * from RaNgE(2);
+
+-- Explain
+EXPLAIN select * from RaNgE(2);

http://git-wip-us.apache.org/repos/asf/spark/blob/58c9e6e7/sql/core/src/test/resources/sql-tests/results/table-valued-functions.sql.out
----------------------------------------------------------------------
diff --git 
a/sql/core/src/test/resources/sql-tests/results/table-valued-functions.sql.out 
b/sql/core/src/test/resources/sql-tests/results/table-valued-functions.sql.out
index d769bce..acd4ecf 100644
--- 
a/sql/core/src/test/resources/sql-tests/results/table-valued-functions.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/results/table-valued-functions.sql.out
@@ -1,5 +1,5 @@
 -- Automatically generated by SQLQueryTestSuite
--- Number of queries: 7
+-- Number of queries: 9
 
 
 -- !query 0
@@ -85,3 +85,21 @@ struct<>
 -- !query 6 output
 java.lang.IllegalArgumentException
 Invalid arguments for resolved function: 1, null
+
+
+-- !query 7
+select * from RaNgE(2)
+-- !query 7 schema
+struct<id:bigint>
+-- !query 7 output
+0
+1
+
+
+-- !query 8
+EXPLAIN select * from RaNgE(2)
+-- !query 8 schema
+struct<plan:string>
+-- !query 8 output
+== Physical Plan ==
+*Range (0, 2, step=1, splits=None)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to