You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Anurag Mantripragada (Jira)" <ji...@apache.org> on 2026/10/10 20:20:00 UTC

[jira] [Updated] (SPARK-60075) Avoid infinite recursion in toString of a V2 expression that V2ExpressionSQLBuilder does not know

     [ https://issues.apache.org/jira/browse/SPARK-60075?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anurag Mantripragada updated SPARK-60075:
-----------------------------------------
    Description: 
SPARK-59983 fixed the StackOverflowError in toString of a {{GeneralScalarExpression}} with an unknown name. One case remains. A connector PartitionPredicate that overrides neither toString nor describe still recurses: {{V2ExpressionSQLBuilder.visitPartitionPredicate}} returns describe(), which defaults to ExpressionWithToString.toString, which calls build again, until a StackOverflowError.

A parent such as Not, And or Cast wrapping such a predicate, or a pushdown builder that reaches it, recurses the same way. Spark's own PartitionPredicateImpl overrides toString, so built-in code paths are not affected.

SPARK-34586 (https://github.com/apache/spark/pull/58153) works around it for DESCRIBE TABLE EXTENDED of a declared write ordering.

  was:
V2ExpressionSQLBuilder.visitUnexpectedExpr builds its UNEXPECTED_V2_EXPRESSION error with String.valueOf(expr). For an ExpressionWithToString (for example a GeneralScalarExpression whose name the builder does not know, such as new GeneralScalarExpression("DATE_TRUNC", ...)), toString() calls ToStringSQLBuilder.build, which reaches visitUnexpectedExpr again, so toString() recurses until StackOverflowError instead of producing a string or a clean error.

Anything that prints such an expression is affected: describe(), log messages, error messages and explain output. SPARK-34586 (https://github.com/apache/spark/pull/58153) works around it for DESCRIBE TABLE EXTENDED of a declared write ordering.

visitUnexpectedExpr should describe the expression without calling its toString(), for example by its class name and the name of a GeneralScalarExpression.



> Avoid infinite recursion in toString of a V2 expression that V2ExpressionSQLBuilder does not know
> -------------------------------------------------------------------------------------------------
>
>                 Key: SPARK-60075
>                 URL: https://issues.apache.org/jira/browse/SPARK-60075
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 5.0.0
>            Reporter: Anurag Mantripragada
>            Priority: Major
>
> SPARK-59983 fixed the StackOverflowError in toString of a {{GeneralScalarExpression}} with an unknown name. One case remains. A connector PartitionPredicate that overrides neither toString nor describe still recurses: {{V2ExpressionSQLBuilder.visitPartitionPredicate}} returns describe(), which defaults to ExpressionWithToString.toString, which calls build again, until a StackOverflowError.
> A parent such as Not, And or Cast wrapping such a predicate, or a pushdown builder that reaches it, recurses the same way. Spark's own PartitionPredicateImpl overrides toString, so built-in code paths are not affected.
> SPARK-34586 (https://github.com/apache/spark/pull/58153) works around it for DESCRIBE TABLE EXTENDED of a declared write ordering.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org