Github user setjet commented on a diff in the pull request: https://github.com/apache/spark/pull/18080#discussion_r118820467 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala --- @@ -402,23 +402,40 @@ case class DayOfMonth(child: Expression) extends UnaryExpression with ImplicitCa } } +// scalastyle:off line.size.limit @ExpressionDescription( - usage = "_FUNC_(date) - Returns the week of the year of the given date.", + usage = "_FUNC_(date[, format]) - Returns the week of the year of the given date. Defaults to ISO 8601 standard, but can be gregorian specific", extended = """ Examples: > SELECT _FUNC_('2008-02-20'); 8 + > SELECT _FUNC_('2017-01-01', 'gregorian'); + 1 + > SELECT _FUNC_('2017-01-01', 'iso'); + 52 + > SELECT _FUNC_('2017-01-01'); + 52 """) -case class WeekOfYear(child: Expression) extends UnaryExpression with ImplicitCastInputTypes { +// scalastyle:on line.size.limit +case class WeekOfYear(child: Expression, format: Expression) extends + UnaryExpression with ImplicitCastInputTypes { + + def this(child: Expression) = { + this(child, Literal("iso")) + } override def inputTypes: Seq[AbstractDataType] = Seq(DateType) override def dataType: DataType = IntegerType + @transient private lazy val minimalDays = { + if ("gregorian".equalsIgnoreCase(format.toString)) 1 else 4 --- End diff -- It will still default to ISO stanards with Monday-Sunday week of course, but now users can override it in any way they would like
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org