MaxGekk commented on a change in pull request #25410: [SPARK-28690][SQL] Add
`date_part` function for timestamps/dates
URL: https://github.com/apache/spark/pull/25410#discussion_r314586294
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
##########
@@ -1409,48 +1409,7 @@ class AstBuilder(conf: SQLConf) extends
SqlBaseBaseVisitor[AnyRef] with Logging
* Create a Extract expression.
*/
override def visitExtract(ctx: ExtractContext): Expression = withOrigin(ctx)
{
- ctx.field.getText.toUpperCase(Locale.ROOT) match {
- case "MILLENNIUM" | "MILLENNIA" | "MIL" | "MILS" =>
- Millennium(expression(ctx.source))
- case "CENTURY" | "CENTURIES" | "C" | "CENT" =>
- Century(expression(ctx.source))
- case "DECADE" | "DECADES" | "DEC" | "DECS" =>
- Decade(expression(ctx.source))
- case "YEAR" | "Y" | "YEARS" | "YR" | "YRS" =>
- Year(expression(ctx.source))
- case "ISOYEAR" =>
- IsoYear(expression(ctx.source))
- case "QUARTER" | "QTR" =>
- Quarter(expression(ctx.source))
- case "MONTH" | "MON" | "MONS" | "MONTHS" =>
- Month(expression(ctx.source))
- case "WEEK" | "W" | "WEEKS" =>
- WeekOfYear(expression(ctx.source))
- case "DAY" | "D" | "DAYS" =>
- DayOfMonth(expression(ctx.source))
- case "DAYOFWEEK" =>
- DayOfWeek(expression(ctx.source))
- case "DOW" =>
- Subtract(DayOfWeek(expression(ctx.source)), Literal(1))
- case "ISODOW" =>
- Add(WeekDay(expression(ctx.source)), Literal(1))
- case "DOY" =>
- DayOfYear(expression(ctx.source))
- case "HOUR" | "H" | "HOURS" | "HR" | "HRS" =>
- Hour(expression(ctx.source))
- case "MINUTE" | "M" | "MIN" | "MINS" | "MINUTES" =>
- Minute(expression(ctx.source))
- case "SECOND" | "S" | "SEC" | "SECONDS" | "SECS" =>
- Second(expression(ctx.source))
- case "MILLISECONDS" | "MSEC" | "MSECS" | "MILLISECON" | "MSECONDS" |
"MS" =>
- Milliseconds(expression(ctx.source))
- case "MICROSECONDS" | "USEC" | "USECS" | "USECONDS" | "MICROSECON" |
"US" =>
- Microseconds(expression(ctx.source))
- case "EPOCH" =>
- Epoch(expression(ctx.source))
- case other =>
- throw new ParseException(s"Literals of type '$other' are currently not
supported.", ctx)
Review comment:
`ParseException` requires either `ctx: ParserRuleContext` or `val start:
Origin, val stop: Origin` that are not available to me at the point. And it is
still `ParseException` in the output:
https://github.com/apache/spark/pull/25410/files#diff-6f4edc80e2cc973e748705e85a6053b4R514
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]