Skip to content

Commit a01aba6

Browse files
committed
remove vars and use actual SQL
1 parent 6efb254 commit a01aba6

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTableValuedFunctions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ object ResolveTableValuedFunctions extends Rule[LogicalPlan] {
103103

104104
override def apply(plan: LogicalPlan): LogicalPlan = plan resolveOperators {
105105
case u: UnresolvedTableValuedFunction if u.functionArgs.forall(_.resolved) =>
106-
builtinFunctions.get(u.functionName) match {
106+
builtinFunctions.get(u.functionName.toLowerCase()) match {
107107
case Some(tvf) =>
108108
val resolved = tvf.flatMap { case (argList, resolver) =>
109109
argList.implicitCast(u.functionArgs) match {

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ case class UnresolvedInlineTable(
6969
* select * from range(10);
7070
* }}}
7171
*/
72-
case class UnresolvedTableValuedFunction(var functionName: String, functionArgs: Seq[Expression])
72+
case class UnresolvedTableValuedFunction(functionName: String, functionArgs: Seq[Expression])
7373
extends LeafNode {
7474

75-
functionName = functionName.toLowerCase()
7675
override def output: Seq[Attribute] = Nil
7776

7877
override lazy val resolved = false

sql/core/src/test/resources/sql-tests/inputs/table-valued-functions.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ select * from range(1, 1, 1, 1, 1);
1818

1919
-- range call with null
2020
select * from range(1, null);
21+
22+
-- range call with a mixed-case function name
23+
select * from RaNgE(2);
24+
25+
-- Explain
26+
EXPLAIN select * from RaNgE(2);

sql/core/src/test/resources/sql-tests/results/table-valued-functions.sql.out

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 7
2+
-- Number of queries: 9
33

44

55
-- !query 0
@@ -85,3 +85,21 @@ struct<>
8585
-- !query 6 output
8686
java.lang.IllegalArgumentException
8787
Invalid arguments for resolved function: 1, null
88+
89+
90+
-- !query 7
91+
select * from RaNgE(2)
92+
-- !query 7 schema
93+
struct<id:bigint>
94+
-- !query 7 output
95+
0
96+
1
97+
98+
99+
-- !query 8
100+
EXPLAIN select * from RaNgE(2)
101+
-- !query 8 schema
102+
struct<plan:string>
103+
-- !query 8 output
104+
== Physical Plan ==
105+
*Range (0, 2, step=1, splits=None)

0 commit comments

Comments
 (0)