NarekDW opened a new pull request, #39720:
URL: https://github.com/apache/spark/pull/39720

   ### What changes were proposed in this pull request?
   `YearMonthIntervalType` case was missed in 
`org.apache.spark.sql.catalyst.analysis.Analyzer.ResolveBinaryArithmetic` 
class. 
   Because of that, such kind of queries:
   `spark.sql("select '2022-02-01' - interval 1 year")` 
   `spark.sql("select '2022-02-01' + interval 1 year")` 
   were failing.
   
   ### Why are the changes needed?
   To fix the interval related operations (add/subtract years/months) bug.
   Previously Spark was trying to cast the date ('2022-02-01') to `DoubleType`.
   
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, it allows users to use interval related operations (add/subtract 
years/months) again.
   Also, because of this change, some error messages were changed:
   - `UNEXPECTED_INPUT_TYPE` -> `BINARY_OP_DIFF_TYPES` (when trying to 
add/subtract different interval types, like `INTERVAL '2' YEAR + INTERVAL '02' 
SECOND`)
   - `BINARY_OP_DIFF_TYPES` ->  `UNEXPECTED_INPUT_TYPE` (when trying to 
add/subtract an interval from some value, like `1 + INTERVAL '2' MONTH`)
   
   ### How was this patch tested?
   An additional test case was added to 
`org.apache.spark.sql.DateFunctionsSuite` class
   


-- 
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-unsubscr...@spark.apache.org

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


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

Reply via email to