You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/09/09 16:34:09 UTC

[GitHub] [spark] Bahigac commented on pull request #35220: [SPARK-37922][SQL] Combine to one cast if we can safely up-cast two casts

Bahigac commented on PR #35220:
URL: https://github.com/apache/spark/pull/35220#issuecomment-1242201044

   > ### What changes were proposed in this pull request?
   > 
   > 
   > 
   > This PR improves `SimplifyCasts` to combine into one cast if they are both `NumericType` and can safely up-cast two casts. For example:
   > 
   > 
   > 
   > ```scala
   > 
   > spark.sql("CREATE TABLE t1 (id int) using parquet")
   > 
   > spark.sql("SELECT CAST(CAST(id AS DECIMAL(10, 0)) AS DECIMAL(12, 2)) FROM t1").explain(true)
   > 
   > ```
   > 
   > Before this pr:
   > 
   > ```
   > 
   > == Optimized Logical Plan ==
   > 
   > Project [cast(cast(id#1 as decimal(10,0)) as decimal(12,2)) AS casted#0]
   > 
   > +- Relation default.t1[id#1] parquet
   > 
   > ```
   > 
   > 
   > 
   > After this pr:
   > 
   > ```
   > 
   > == Optimized Logical Plan ==
   > 
   > Project [cast(id#1 as decimal(12,2)) AS casted#0]
   > 
   > +- Relation default.t1[id#1] parquet
   > 
   > ```
   > 
   > 
   > 
   > 
   > 
   > 
   > 
   > ### Why are the changes needed?
   > 
   > 
   > 
   > Improve query performance.
   > 
   > 
   > 
   > ### Does this PR introduce _any_ user-facing change?
   > 
   > 
   > 
   > No.
   > 
   > 
   > 
   > ### How was this patch tested?
   > 
   > 
   > 
   > Unit test.
   
   


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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