Skip to content

Conversation

uros-db
Copy link
Contributor

@uros-db uros-db commented Oct 8, 2025

What changes were proposed in this pull request?

Properly preserve Project node tags (including the plan ID) in plan rewrites under the ResolveSQLFunctions analyzer rule.

Why are the changes needed?

Fix an issue with incorrectly dropped plan IDs, causing query failures (CANNOT_RESOLVE_DATAFRAME_COLUMN) when using Spark Connect.

Does this PR introduce any user-facing change?

Yes, some failing queries will now work properly with Spark Connect.

How was this patch tested?

Added a new test in a Spark Connect scala suite.

Was this patch authored or co-authored using generative AI tooling?

No.

@uros-db uros-db changed the title [SQL] Fix PlanID preservation in ResolveSQLFunctions with UDFs [SPARK-53855][SQL] Fix PlanID preservation in ResolveSQLFunctions with UDFs Oct 9, 2025
@uros-db
Copy link
Contributor Author

uros-db commented Oct 9, 2025


test("preserve plan ID in ResolveSQLFunctions with UDF") {
// Create a simple SQL function / UDF for testing purposes.
spark.sql("""CREATE OR REPLACE FUNCTION funct(x INT) RETURNS STRING RETURN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's wrap the test with withUserDefinedFunction

.sql("SELECT * FROM VALUES (0, 1)")
.select(expr("funct(col1)").alias("col2"))
// Now use the UDF in a query that will initiate plan rewrite by ResolveSQLFunctions.
df.groupBy("col2").agg(count("*")).explain(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use checkAnswer?

@uros-db uros-db changed the title [SPARK-53855][SQL] Fix PlanID preservation in ResolveSQLFunctions with UDFs [WIP][SPARK-53855][SQL] Fix PlanID preservation in ResolveSQLFunctions with UDFs Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants