LuciferYang commented on code in PR #44758:
URL: https://github.com/apache/spark/pull/44758#discussion_r1454655394
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -7303,6 +7303,36 @@ def monthname(col: "ColumnOrName") -> Column:
return _invoke_function_over_columns("monthname", col)
+@_try_remote_functions
+def dayname(col: "ColumnOrName") -> Column:
+ """
+ Returns the three-letter abbreviated day name from the given date.
Review Comment:
`Date and Timestamp Function: Returns the three-letter ...`
##########
python/pyspark/sql/tests/test_functions.py:
##########
@@ -421,6 +421,12 @@ def test_monthname(self):
row = df.select(F.monthname(df.date)).first()
self.assertEqual(row[0], "Nov")
+ def test_dayname(self):
+ dt = datetime.datetime(2017, 11, 6)
Review Comment:
Indentation
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -7303,6 +7303,36 @@ def monthname(col: "ColumnOrName") -> Column:
return _invoke_function_over_columns("monthname", col)
+@_try_remote_functions
+def dayname(col: "ColumnOrName") -> Column:
+ """
+ Returns the three-letter abbreviated day name from the given date.
+
+ .. versionadded:: 4.0.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or str
+ target date/timestamp column to work on.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ the three-letter abbreviation of day name for date/timestamp (Mon,
Tue, Wed...)
+
+ Examples
+ --------
Review Comment:
1. Please give a name to Example.
2. Try not to use `.alias('day')` as much as possible.
3. Please use the `from pyspark.sql import functions as sf/import
pyspark.sql.functions as sf` ... `sf.dayname` approach to write the example.
This is to maintain consistency with the already refined examples.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]