You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by HyukjinKwon <gi...@git.apache.org> on 2017/12/19 07:13:00 UTC

[GitHub] spark pull request #20015: [SPARK-22829] Add new built-in function date_trun...

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

    https://github.com/apache/spark/pull/20015#discussion_r157673559
  
    --- Diff: python/pyspark/sql/functions.py ---
    @@ -1111,6 +1111,24 @@ def trunc(date, format):
         return Column(sc._jvm.functions.trunc(_to_java_column(date), format))
     
     
    +@since(2.3)
    +def date_trunc(format, timestamp):
    +    """
    +    Returns timestamp truncated to the unit specified by the format.
    +
    +    :param format: 'year', 'YYYY', 'yy', 'month', 'mon', 'mm',
    +        'DAY', 'DD', 'HOUR', 'MINUTE', 'SECOND', 'WEEK', 'QUARTER'
    +
    +    >>> df = spark.createDataFrame([('1997-02-28',)], ['d'])
    --- End diff --
    
    Can we use a timestamp string like `1997-02-28 05:02:11` to show the difference from `trunc` a bit more clearly?


---

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