voonhous commented on code in PR #19853:
URL: https://github.com/apache/hudi/pull/19853#discussion_r3961142047
##########
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/HoodieProcedureFilterUtils.scala:
##########
@@ -389,6 +398,41 @@ object HoodieProcedureFilterUtils {
}
}
+ // didn't match anything above, so ask Spark itself before we give up -
saves us from having
+ // to hand-list every builtin (concat, instr, if, ...) one by one
+ private def resolveViaFunctionRegistry(unresolvedFunc: UnresolvedFunction,
sparkSession: SparkSession): Expression = {
+ Try {
+ val nameParts = unresolvedFunc.nameParts
+ val functionIdentifier = nameParts match {
Review Comment:
Addressed by rejecting instead of documenting: a 3+ part name now yields no
`FunctionIdentifier` and falls through to the rejection path, with a comment on
why. `some_catalog.some_db.upper(name)` is pinned as rejected.
##########
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/HoodieProcedureFilterUtils.scala:
##########
@@ -389,6 +398,48 @@ object HoodieProcedureFilterUtils {
}
}
+ // didn't match anything above, so ask Spark itself before we give up -
saves us from having
+ // to hand-list every builtin (concat, instr, if, ...) one by one
+ private def resolveViaFunctionRegistry(unresolvedFunc: UnresolvedFunction,
sparkSession: SparkSession): Expression = {
+ Try {
+ val nameParts = unresolvedFunc.nameParts
+ // Filter expressions only ever call plain or db-qualified builtins, so
this is really just
+ // name/db.name. A 3+ part name (catalog.db.func) isn't something we can
look up safely -
+ // FunctionIdentifier only carries one qualifier, and guessing by
dropping the extra parts
+ // risks matching a same-named function that isn't the one that was
actually asked for. Bail
+ // out to unresolvedFunc instead and let it fall through to the existing
rejection path.
+ val functionIdentifier = nameParts match {
+ case Seq(funcName) => Some(FunctionIdentifier(funcName))
+ case Seq(db, funcName) => Some(FunctionIdentifier(funcName, Some(db)))
+ case _ => None
+ }
+ val resolved = functionIdentifier
+ .map(sparkSession.sessionState.functionRegistry.lookupFunction(_,
unresolvedFunc.arguments))
+ .getOrElse(unresolvedFunc)
+ // lookupFunction on its own leaves nvl/ifnull/left/right etc as a
placeholder - normally
+ // the analyzer swaps it for the real expression right after, but nobody
does that here, so
+ // eval() just throws. Unwrap it ourselves instead.
+ val unwrapped = resolved.transformUp { case r: RuntimeReplaceable =>
r.replacement }
+ // a few more things resolve fine here but still can't be eval()'d one
row at a time:
+ // aggregates (percentile, collect_list) need real aggregation,
generators (explode,
+ // inline) only work inside a projection, and non-deterministic funcs
(rand, uuid,
+ // spark_partition_id) expect per-partition init we never do. Push all
of those back to
+ // unresolved so #19850's rejection path catches them instead of quietly
dropping every row.
+ val stillUnsupported =
+
unwrapped.isInstanceOf[org.apache.spark.sql.catalyst.expressions.aggregate.AggregateFunction]
||
Review Comment:
Addressed: the guard now includes `!unwrapped.resolved ||
!unwrapped.checkInputDataTypes().isSuccess`. `concat(id, 'x')` is pinned as
rejected by both `validateFilterExpression` and `evaluateFilter`.
--
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]