dongjoon-hyun opened a new pull request, #59241:
URL: https://github.com/apache/spark/pull/59241

   ### What changes were proposed in this pull request?
   
   This PR aims to fix `ToStringSQLBuilder` to render a 
`GeneralScalarExpression` with an unknown name as a function call, e.g., 
`DATE_TRUNC('MONTH', ts)`.
   
   ### Why are the changes needed?
   
   Currently, `toString` and `describe` of a V2 expression with an unknown name 
fail with `StackOverflowError`, because 
`V2ExpressionSQLBuilder.visitUnexpectedExpr` builds its error message with 
`toString` of the same expression.
   
   ```scala
   import org.apache.spark.sql.connector.expressions.{Expression, Expressions, 
GeneralScalarExpression}
   
   val e = new GeneralScalarExpression("DATE_TRUNC",
     Array[Expression](Expressions.literal("MONTH"), Expressions.column("ts")))
   e.toString  // java.lang.StackOverflowError
   ```
   
   This is a regression since Apache Spark 
[v3.4.0](https://github.com/apache/spark/releases/tag/v3.4.0) (2023-04-07) by 
[SPARK-39139](https://issues.apache.org/jira/browse/SPARK-39139).
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `toString` and `describe` return a string like `DATE_TRUNC('MONTH', 
ts)` instead of throwing `StackOverflowError`. Known names are rendered as 
before, and the SQL builders for pushdown still reject such expressions with 
`UNEXPECTED_V2_EXPRESSION`.
   
   ### How was this patch tested?
   
   Pass the CIs with the newly added test case.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to