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 2021/12/30 13:40:38 UTC

[GitHub] [spark] zero323 commented on pull request #35032: [SPARK-37738][PYTHON] Support column type inputs for second arg of date manipulation functions

zero323 commented on pull request #35032:
URL: https://github.com/apache/spark/pull/35032#issuecomment-1003033776


   No worries. Sadly, linters don't catch these. 
   
   As of this:
   
   > All makes sense to me; I'd be happy to write this in a ticket and make a PR to correct some of the input parameters over the next few days.
   
   ‒ we don't seem to have many of these left. `least` (which is matter of fixing the annotation, as code already supports it) is one.  The other one is `when` which is somewhat disputable; value and otherwise can take plain literals (including strings)  which are interpreted as-is
   
   ```python
   >>> spark.range(1).select(
   ...     when(lit(False), "foo").otherwise("bar"),
   ...     when(lit(True), "foo").otherwise("bar")
   ... ).show()
   ##  +-------------------------------------+------------------------------------+
   ## |CASE WHEN false THEN foo ELSE bar END|CASE WHEN true THEN foo ELSE bar END|
   ## +-------------------------------------+------------------------------------+
   ## |                                  bar|                                 foo| 
   ## +-------------------------------------+------------------------------------+
   
   ```
   
   so I am not sure if we want to change anything there. This
   
   ```python
   when(col("baz"), "foo").otherwise("bar")
   ```
   
   is explicit, while
   
   ```python
   when("baz", "foo").otherwise("bar")
   ```
   
   might be confusing, suggesting that all strings have the same meaning, which is not the case.


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