Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-50693][CONNECT] The inputs for TypedScalaUdf should be analyzed #49327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ueshin
Copy link
Member

@ueshin ueshin commented Dec 27, 2024

What changes were proposed in this pull request?

Fixes SparkConnectPlanner to analyze the inputs for TypedScalaUdf.

Why are the changes needed?

The inputs for TypedScalaUdf should be analyzed.

For example:

val df = Seq(("a", 10), ("a", 20), ("b", 1), ("b", 2), ("c", 1)).toDF("c1", "c2")
df.select("*").filter(r => r.getInt(1) > 5)

fails with:

org.apache.spark.SparkException: [INTERNAL_ERROR] Invalid call to toAttribute on unresolved object SQLSTATE: XX000
  at org.apache.spark.sql.catalyst.analysis.Star.toAttribute(unresolved.scala:438)
  at org.apache.spark.sql.catalyst.plans.logical.Project.$anonfun$output$1(basicLogicalOperators.scala:74)
  at scala.collection.immutable.List.map(List.scala:247)
  at scala.collection.immutable.List.map(List.scala:79)
  at org.apache.spark.sql.catalyst.plans.logical.Project.output(basicLogicalOperators.scala:74)
  at org.apache.spark.sql.connect.planner.SparkConnectPlanner.transformTypedFilter(SparkConnectPlanner.scala:1460)
  at org.apache.spark.sql.connect.planner.SparkConnectPlanner.transformFilter(SparkConnectPlanner.scala:1437)
...

Does this PR introduce any user-facing change?

The failure will not appear.

How was this patch tested?

Added the related tests.

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

No.

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