maropu 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_r314962673
########## 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: Ur, I don't think the approach is bad and I'm just looking for a better solution to keep the current error handling. If we already have the similar logic, can we follow that? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org