cloud-fan commented on code in PR #36663:
URL: https://github.com/apache/spark/pull/36663#discussion_r903241878


##########
sql/core/src/main/scala/org/apache/spark/sql/catalyst/util/V2ExpressionBuilder.scala:
##########
@@ -262,6 +262,55 @@ class V2ExpressionBuilder(
       } else {
         None
       }
+    case date: DateAdd =>
+      val childrenExpressions = date.children.flatMap(generateExpression(_))
+      if (childrenExpressions.length == date.children.length) {
+        Some(new GeneralScalarExpression("DATE_ADD", 
childrenExpressions.toArray[V2Expression]))
+      } else {
+        None
+      }
+    case date: DateDiff =>
+      val childrenExpressions = date.children.flatMap(generateExpression(_))
+      if (childrenExpressions.length == date.children.length) {
+        Some(new GeneralScalarExpression("DATE_DIFF", 
childrenExpressions.toArray[V2Expression]))
+      } else {
+        None
+      }
+    case date: TruncDate =>
+      val childrenExpressions = date.children.flatMap(generateExpression(_))
+      if (childrenExpressions.length == date.children.length) {
+        Some(new GeneralScalarExpression("TRUNC", 
childrenExpressions.toArray[V2Expression]))
+      } else {
+        None
+      }
+    case Second(child, _) => generateExpression(child)
+      .map(v => new GeneralScalarExpression("SECOND", Array[V2Expression](v)))

Review Comment:
   let's translate to `EXTRACT` earlier. We should translate these catalyst 
field extraction functions to v2 `EXTRACT` function, which has 2 parameters: 
the input datetime, and the field string. 



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to