Skip to content

Commit

Permalink
Fixed typos and used LocalDate
Browse files Browse the repository at this point in the history
  • Loading branch information
PetarVasiljevic-DB committed Jan 17, 2024
1 parent 11573de commit e7611c9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion R/pkg/R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ setMethod("monthname",
})

#' @details
#' \code{dayname}: Extracts the three-letter abbreviated month name from a
#' \code{dayname}: Extracts the three-letter abbreviated day name from a
#' given date/timestamp/string.
#'
#' @rdname column_datetime_functions
Expand Down
14 changes: 7 additions & 7 deletions python/pyspark/sql/functions/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7306,7 +7306,7 @@ def monthname(col: "ColumnOrName") -> Column:
@_try_remote_functions
def dayname(col: "ColumnOrName") -> Column:
"""
Returns the three-letter abbreviated day name from the given date.
Date and Timestamp Function: Returns the three-letter abbreviated day name from the given date.

.. versionadded:: 4.0.0

Expand All @@ -7323,12 +7323,12 @@ def dayname(col: "ColumnOrName") -> Column:
Examples
--------
>>> df = spark.createDataFrame([('2015-04-08',)], ['dt'])
>>> df.select(dayname('dt').alias('day')).show()
+-----+
|day|
+-----+
|Wed|
+-----+
>>> df.select(dayname('dt').alias('dayname')).show()
+-------+
|dayname|
+-------+
| Wed|
+-------+
"""
return _invoke_function_over_columns("dayname", col)

Expand Down
8 changes: 4 additions & 4 deletions python/pyspark/sql/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ def test_monthname(self):
self.assertEqual(row[0], "Nov")

def test_dayname(self):
dt = datetime.datetime(2017, 11, 6)
df = self.spark.createDataFrame([Row(date=dt)])
row = df.select(F.dayname(df.date)).first()
self.assertEqual(row[0], "Mon")
dt = datetime.datetime(2017, 11, 6)
df = self.spark.createDataFrame([Row(date=dt)])
row = df.select(F.dayname(df.date)).first()
self.assertEqual(row[0], "Mon")

# Test added for SPARK-37738; change Python API to accept both col & int as input
def test_date_add_function(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,6 @@ case class MonthName(child: Expression) extends GetDateField {
copy(child = newChild)
}

// scalastyle:off line.size.limit
@ExpressionDescription(
usage = "_FUNC_(date) - Returns the three-letter abbreviated day name from the given date.",
examples = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation(DayName(Cast(Literal(date), DateType, UTC_OPT)), "Wed")
checkEvaluation(DayName(Cast(Literal(ts), DateType, UTC_OPT)), "Fri")
checkEvaluation(DayName(Cast(Literal("2011-05-06"), DateType, UTC_OPT)), "Fri")
checkEvaluation(DayName(Literal(new Date(toMillis("2017-05-27 13:10:15")))), "Sat")
checkEvaluation(DayName(Literal(new Date(toMillis("1582-10-15 13:10:15")))), "Fri")
checkEvaluation(DayName(Literal(LocalDate.parse("2017-05-27"))), "Sat")
checkEvaluation(DayName(Literal(LocalDate.parse("1582-10-15"))), "Fri")
checkConsistencyBetweenInterpretedAndCodegen(DayName, DateType)
}

Expand Down

0 comments on commit e7611c9

Please sign in to comment.