Skip to content
Snippets Groups Projects
Commit 58c9e6e7 authored by samelamin's avatar samelamin Committed by Reynold Xin
Browse files

[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.elamin@gmail.com>
Author: samelamin <sam_elamin@discovery.com>

Closes #17487 from samelamin/SPARK-20145.
parent 703c42c3
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
......@@ -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);
-- 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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment