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

   ### What changes were proposed in this pull request?
   
   Allows bare literals for `__and__` and `__or__` of Column API in Spark 
Classic.
   
   ### Why are the changes needed?
   
   Currently bare literals are not allowed for `__and__` and `__or__` of Column 
API in Spark Classic and need to wrap with `lit()` function. It should be 
allowed similar to other similar operators.
   
   ```py
   >>> from pyspark.sql.functions import *
   >>> c = col("c")
   >>> c & True
   Traceback (most recent call last):
   ...
   py4j.Py4JException: Method and([class java.lang.Boolean]) does not exist
   
   >>> c & lit(True)
   Column<'and(c, true)'>
   ```
   
   whereas other operators:
   
   ```py
   >>> c + 1
   Column<'`+`(c, 1)'>
   >>> c + lit(1)
   Column<'`+`(c, 1)'>
   ```
   
   Spark Connect allows this.
   
   ```py
   >>> c & True
   Column<'and(c, True)'>
   >>> c & lit(True)
   Column<'and(c, True)'>
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes.
   
   ### How was this patch tested?
   
   Added the related tests.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No.
   


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