daniel-lunin-db commented on code in PR #56902:
URL: https://github.com/apache/spark/pull/56902#discussion_r3507120235
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SQLFunction.scala:
##########
@@ -299,6 +300,27 @@ object SQLFunction {
parser.parseExpression(text)
}
+ /**
+ * Pads `arguments` with the trailing parameters' declared defaults so the
result aligns
+ * one-to-one with `param`'s fields, parsing each default and casting it to
the parameter type.
+ * A missing parameter without a default raises
[[QueryCompilationErrors.wrongNumArgsError]].
+ */
+ def padArgumentsWithDefaults(
+ arguments: Seq[Expression],
+ param: StructType,
+ functionName: String,
+ parser: ParserInterface): Seq[Expression] = {
+ arguments ++ param.takeRight(param.size - arguments.size).map { field =>
+ field.getDefault() match {
+ case Some(default) =>
+ Cast(parseDefault(default, parser), field.dataType)
Review Comment:
@MaxGekk good catch, the summary was stale from an earlier version. It's
intentionally scalar-only: a straight, byte-identical extraction of
`makeSQLFunctionPlan`'s existing logic, cast included, and
`makeSQLTableFunctionPlan` keeps its own padding.
I kept it byte-identical on purpose to keep this a pure extraction. The
padding cast seems to be redundant given the downstream `Alias(Cast(outer,
param.dataType))`, but dropping it and moving the table path onto an untyped
helper is a separate cleanup I left out of scope. Factored into `SQLFunction`
for reuse, the single-pass analyzer needs the same padding.
Fixed the description to match.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]