cloud-fan commented on a change in pull request #25367: [SPARK-28623][SQL] 
Support `dow`, `isodow` and `doy` by `extract()`
URL: https://github.com/apache/spark/pull/25367#discussion_r410044937
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ##########
 @@ -1408,6 +1408,12 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
         DayOfMonth(expression(ctx.source))
       case "DAYOFWEEK" =>
         DayOfWeek(expression(ctx.source))
+      case "DOW" =>
+        Subtract(DayOfWeek(expression(ctx.source)), Literal(1))
 
 Review comment:
   We never promise pgsql compatibility and internal consistency is much more 
important for Spark.
   
   For this case, I think the behavior of `DOW` from pgsql is correct and 
commonly used by other databases. We should fix our `DAYOFWEEK` instead.
   

----------------------------------------------------------------
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]

Reply via email to