Skip to content

Commit 17c91f4

Browse files
committed
Handled for expressions that take more than 1 parameter
1 parent 3c87222 commit 17c91f4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,13 +637,13 @@ object FunctionRegistry {
637637
.filter(_.getParameterTypes.head == classOf[String])
638638
assert(constructors.length == 1)
639639
val builder = (expressions: Seq[Expression]) => {
640-
assert(expressions.size == 1,
641-
s"Invalid number of arguments for function $name. " +
640+
val params = classOf[String] +: Seq.fill(expressions.size)(classOf[Expression])
641+
val f = constructors.find(_.getParameterTypes.toSeq == params).getOrElse {
642+
throw new AnalysisException(s"Invalid number of arguments for function $name. " +
642643
s"Expected: 1; Found: ${expressions.size}")
643-
assert(expressions.head == classOf[Expression],
644-
s"Invalid arguments for function $name")
644+
}
645645
try {
646-
constructors.head.newInstance(name.toString, expressions.head).asInstanceOf[Expression]
646+
f.newInstance(name.toString +: expressions: _*).asInstanceOf[Expression]
647647
} catch {
648648
// the exception is an invocation exception. To get a meaningful message, we need the
649649
// cause.

0 commit comments

Comments
 (0)