File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -572,8 +572,21 @@ def _normalize_udf(
572572
573573 if isinstance (udf , str ):
574574 parsed : exp .Expression = exp .maybe_parse (udf , dialect = dialect )
575- udf = parsed if isinstance (parsed , exp .Anonymous ) else parsed .this
575+ # When parsing qualified UDF strings (e.g. "db.my_func()"), the root
576+ # expression may be a Dot, with the Anonymous function call nested
577+ # inside. Find the actual Anonymous node instead of blindly taking
578+ # the left-hand side.
579+ if isinstance (parsed , exp .Anonymous ):
580+ udf_expr = parsed
581+ elif isinstance (parsed , exp .Expression ):
582+ udf_expr = parsed .find (exp .Anonymous )
583+ else :
584+ udf_expr = None
585+
586+ if not isinstance (udf_expr , exp .Anonymous ):
587+ raise SchemaError (f"Unable to parse UDF from: { udf !r} " )
576588
589+ udf = udf_expr
577590 parts = self .udf_parts (udf )
578591
579592 if normalize :
You can’t perform that action at this time.
0 commit comments