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

Gengliang Wang resolved SPARK-52575.
------------------------------------
    Fix Version/s: 4.1.0
       Resolution: Fixed

Issue resolved by pull request 51282
[https://github.com/apache/spark/pull/51282]

> Introduce contextIndependentFoldable attribute for Expressions
> --------------------------------------------------------------
>
>                 Key: SPARK-52575
>                 URL: https://issues.apache.org/jira/browse/SPARK-52575
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 4.1.0
>            Reporter: Gengliang Wang
>            Assignee: Gengliang Wang
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.1.0
>
>
> Introduces a method to determine whether an expression can be folded without 
> relying on any external context (e.g., time zone, session configurations, or 
> catalogs). If an expression is context-independent foldable, it can be safely 
> evaluated during DDL operations such as creating tables, views, or 
> constraints. This enables systems to store the computed value rather than the 
> original expression, simplifying implementation and improving performance. By 
> default, expressions are not considered context-independent foldable to 
> ensure explicit annotation of context independence.
>  
> *Good examples (context-independent foldable):*
>  * 1 + 1
> _Always produces 2, regardless of context._
>  * 1 > 0
> _Always evaluates to true._
>  * CAST('2025-08-01' AS DATE)
> _Always gives the same date value._
>  
> {*}Bad examples (not context-independent foldable):{*}{*}{*}
>  * CURRENT_DATE
> _Result depends on the current date and time zone._
>  * CURRENT_USER
> _Result depends on the session/user context._
>  * CAST('2025-08-01 00:00:00' AS TIMESTAMP)
> _Result can vary depending on the session time zone setting_
>  



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

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

Reply via email to