Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2824,6 +2824,10 @@ class Analyzer(
j.copy(left = newLeft, right = newRight)
}

// Allow scalar SQL UDFs in SQL table function inputs. They will be resolved
// when ResolveSQLTableFunctions expands the table function via executeSameContext.
case f: SQLTableFunction if hasSQLFunctionExpression(f.expressions) => f

case o: LogicalPlan if o.resolved && hasSQLFunctionExpression(o.expressions) =>
o.transformExpressionsWithPruning(_.containsPattern(SQL_FUNCTION_EXPRESSION)) {
case f: SQLFunctionExpression =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,16 @@ class SQLFunctionSuite extends SharedSparkSession {
}
}
}

test("SPARK-52719: scalar SQL UDF as TVF argument") {
withUserDefinedFunction("scalar_udf" -> false, "table_func" -> false) {
sql("CREATE FUNCTION scalar_udf(x INT) RETURNS INT RETURN x + 1")
sql(
"""CREATE FUNCTION table_func(x INT)
|RETURNS TABLE(a INT)
|RETURN SELECT x
|""".stripMargin)
checkAnswer(sql("SELECT * FROM table_func(scalar_udf(1))"), Row(2))
}
}
}