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

    https://github.com/apache/spark/pull/6981#discussion_r34950829
  
    --- Diff: python/pyspark/sql/functions.py ---
    @@ -652,6 +652,164 @@ def ntile(n):
         return Column(sc._jvm.functions.ntile(int(n)))
     
     
    +@ignore_unicode_prefix
    +@since(1.5)
    +def date_format(dateCol, format):
    +    """
    +    Converts a date/timestamp/string to a value of string in the format 
specified by the date
    +    format given by the second argument.
    +
    +    A pattern could be for instance `dd.MM.yyyy` and could return a string 
like '18.03.1993'. All
    +    pattern letters of the Java class `java.text.SimpleDateFormat` can be 
used.
    +
    +    NOTE: Use when ever possible specialized functions like `year`. These 
benefit from a
    +    specialized implementation.
    +
    +    >>> df0 = sqlContext.createDataFrame([('2015-04-08',)], ['a'])
    +
    +    >>> df0.select(date_format('a', 'MM/dd/yyy').alias('date')).collect()
    +    [Row(date=u'04/08/2015')]
    +    """
    +    sc = SparkContext._active_spark_context
    +    return Column(sc._jvm.functions.date_format(dateCol, format))
    +
    +
    +@since(1.5)
    +def year(col):
    +    """
    +    Extract the year of a given date as integer.
    +
    +    >>> df0 = sqlContext.createDataFrame([('2015-04-08',)], ['a'])
    +
    +    >>> df0.select(year('a').alias('year')).collect()
    +    [Row(year=2015)]
    +    """
    +    sc = SparkContext._active_spark_context
    +    return Column(sc._jvm.functions.year(col))
    +
    +
    +@since(1.5)
    +def quarter(col):
    +    """
    +    Extract the quarter of a given date as integer.
    +
    +    >>> df0 = sqlContext.createDataFrame([('2015-04-08',)], ['a'])
    +
    +    >>> df0.select(quarter('a').alias('quarter')).collect()
    +    [Row(quarter=2)]
    +    """
    +    sc = SparkContext._active_spark_context
    +    return Column(sc._jvm.functions.quarter(col))
    +
    +
    +@since(1.5)
    +def month(col):
    +    """
    +    Extract the month of a given date as integer.
    +
    +    >>> df0 = sqlContext.createDataFrame([('2015-04-08',)], ['a'])
    +
    +    >>> df0.select(month('a').alias('month')).collect()
    +    [Row(month=4)]
    +   """
    +    sc = SparkContext._active_spark_context
    +    return Column(sc._jvm.functions.month(col))
    +
    +
    +@since(1.5)
    +def day(col):
    +    """
    +    Extract the day of the month of a given date as integer.
    +
    +    >>> sqlContext.createDataFrame([('2015-04-08',)], 
['a']).select(day('a').alias('day')).collect()
    +    [Row(day=8)]
    +    """
    +    sc = SparkContext._active_spark_context
    +    return Column(sc._jvm.functions.day(col))
    +
    +
    +@since(1.5)
    +def day_of_month(col):
    +    """
    +    Extract the day of the month of a given date as integer.
    +
    +    >>> df0 = sqlContext.createDataFrame([('2015-04-08',)], ['a'])
    +
    +    >>> df0.select(day_of_month('a').alias('day')).collect()
    +    [Row(day=8)]
    +    """
    +    sc = SparkContext._active_spark_context
    +    return Column(sc._jvm.functions.day_of_month(col))
    +
    +
    +@since(1.5)
    +def day_in_year(col):
    +    """
    +    Extract the day of the year of a given date as integer.
    +    >>> df0 = sqlContext.createDataFrame([('2015-04-08',)], ['a'])
    --- End diff --
    
    blank line above this.


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