[ 
https://issues.apache.org/jira/browse/BEAM-10240?focusedWorklogId=466509&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-466509
 ]

ASF GitHub Bot logged work on BEAM-10240:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Aug/20 22:55
            Start Date: 04/Aug/20 22:55
    Worklog Time Spent: 10m 
      Work Description: apilloud commented on a change in pull request #12348:
URL: https://github.com/apache/beam/pull/12348#discussion_r465373933



##########
File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/ExpressionConverter.java
##########
@@ -850,6 +848,25 @@ private RexNode convertSimpleValueToRexNode(TypeKind kind, 
Value value) {
         // TODO: Doing micro to mills truncation, need to throw exception.
         ret = rexBuilder().makeLiteral(convertTimeValueToTimeString(value), 
timeType, false);
         break;
+      case TYPE_DATETIME:
+        // Cannot simply call makeTimestampWithLocalTimeZoneLiteral() for 
ZetaSQL DATETIME type
+        // because later it will be unparsed to the string representation of 
timestamp (e.g. "SELECT
+        // DATETIME '2008-12-25 15:30:00'" will be unparsed to "SELECT 
TIMESTAMP '2008-12-25
+        // 15:30:00:000000'"). So we create a wrapper function here such that 
we can later recognize
+        // it and customize its unparsing in BeamBigQuerySqlDialect.
+        ret =
+            rexBuilder()
+                .makeCall(
+                    SqlOperators.createZetaSqlFunction(
+                        BeamBigQuerySqlDialect.DATETIME_LITERAL_FUNCTION,

Review comment:
       Instead of wrapping with a function here, it looks like you can do the 
same thing by creating a class overloading `SqlTimestampLiteral.toString()` and 
wrapping it in `BeamSqlUnparseContext`? This would reduce the complexity at the 
Rel layer.
   
https://github.com/apache/beam/blob/6fdde4f4eab72b49b10a8bb1cb3be263c5c416b5/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/bigquery/BeamSqlUnparseContext.java#L70




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 466509)
    Time Spent: 2h 40m  (was: 2.5h)

> Support ZetaSQL DATETIME functions in BeamSQL
> ---------------------------------------------
>
>                 Key: BEAM-10240
>                 URL: https://issues.apache.org/jira/browse/BEAM-10240
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql-zetasql
>            Reporter: Robin Qiu
>            Assignee: Zijie Song
>            Priority: P2
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> Support *all* DATETIME functions defined in ZetaSQL (BigQuery Standard SQL). 
> See the list of functions below:
> [https://github.com/google/zetasql/blob/master/docs/datetime_functions.md|https://github.com/google/zetasql/blob/master/docs/time_functions.md]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to