Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18106#discussion_r123824736
  
    --- Diff: python/pyspark/sql/functions.py ---
    @@ -1028,20 +1028,28 @@ def to_timestamp(col, format=None):
     
     
     @since(1.5)
    -def trunc(date, format):
    +def trunc(data, format):
         """
    -    Returns date truncated to the unit specified by the format.
    +    Returns date truncated to the unit specified by the format or
    +    number truncated by specified decimal places.
     
         :param format: 'year', 'YYYY', 'yy' or 'month', 'mon', 'mm'
     
         >>> df = spark.createDataFrame([('1997-02-28',)], ['d'])
    -    >>> df.select(trunc(df.d, 'year').alias('year')).collect()
    +    >>> df.select(trunc(to_date(df.d), 'year').alias('year')).collect()
         [Row(year=datetime.date(1997, 1, 1))]
    -    >>> df.select(trunc(df.d, 'mon').alias('month')).collect()
    +    >>> df.select(trunc(to_date(df.d), 'mon').alias('month')).collect()
    --- End diff --
    
    Here too. If this change is needed to pass Pyhon tests, it looks breaking 
the compatibility.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to