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

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

                Author: ASF GitHub Bot
            Created on: 04/Feb/20 18:23
            Start Date: 04/Feb/20 18:23
    Worklog Time Spent: 10m 
      Work Description: robinyqiu commented on pull request #10634: [BEAM-9178] 
Support all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#discussion_r374842360
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/bigquery/BeamBigQuerySqlDialect.java
 ##########
 @@ -302,6 +316,38 @@ private void unparseTrim(SqlWriter writer, SqlCall call, 
int leftPrec, int right
     writer.endFunCall(trimFrame);
   }
 
+  /**
+   * For usage of INTERVAL, see <a
+   * 
href="https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#timestamp_add";>
+   * BQ TIMESTAMP_ADD function</a> for example.
+   */
+  private void unparseFunctionsUsingInterval(
+      SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) {
+    // e.g. TIMESTAMP_ADD syntax:
+    // TIMESTAMP_ADD(timestamp_expression, INTERVAL int64_expression date_part)
+    int operandCount = call.operandCount();
+    if (operandCount == 2) {
+      // operand0: timestamp_expression
+      // operand1: SqlIntervalLiteral (INTERVAL int64_expression date_part)
+      super.unparseCall(writer, call, leftPrec, rightPrec);
+    } else if (operandCount == 3) {
+      // operand0: timestamp_expression
+      // operand1: int64_expression
+      // operand2: date_part
+      final SqlWriter.Frame frame = 
writer.startFunCall(call.getOperator().getName());
+      call.operand(0).unparse(writer, leftPrec, rightPrec);
+      writer.literal(",");
+      writer.literal("INTERVAL");
+      call.operand(1).unparse(writer, leftPrec, rightPrec);
+      call.operand(2).unparse(writer, leftPrec, rightPrec);
+      writer.endFunCall(frame);
+    } else {
+      throw new IllegalArgumentException(
+          String.format(
+              "Unable to parse %s with %d operands.", 
call.getOperator().getName(), operandCount));
 
 Review comment:
   Fixed.
 
----------------------------------------------------------------
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


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

    Worklog Id:     (was: 381782)
    Time Spent: 1h 20m  (was: 1h 10m)

> Support ZetaSQL TIMESTAMP functions in BeamSQL
> ----------------------------------------------
>
>                 Key: BEAM-9178
>                 URL: https://issues.apache.org/jira/browse/BEAM-9178
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql-zetasql
>            Reporter: Yueyang Qiu
>            Assignee: Yueyang Qiu
>            Priority: Major
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> Support *all* TIMESTAMP functions defined in ZetaSQL (BigQuery Standard SQL). 
> See the full list of functions below:
> [https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions]



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

Reply via email to