[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-07 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 07/Feb/20 16:44
Start Date: 07/Feb/20 16:44
Worklog Time Spent: 10m 
  Work Description: apilloud commented on issue #10634: [BEAM-9178] Support 
all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-583492733
 
 
   LGTM
 

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: 383716)
Time Spent: 3h 20m  (was: 3h 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: 3h 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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-07 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


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

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: 383717)
Time Spent: 3.5h  (was: 3h 20m)

> 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: 3.5h
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-07 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 07/Feb/20 16:44
Start Date: 07/Feb/20 16:44
Worklog Time Spent: 10m 
  Work Description: apilloud commented on issue #10634: [BEAM-9178] Support 
all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-583492655
 
 
   The failing java precommits are due to #10787 modifying the seed job. 
Ignoring.
 

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: 383715)
Time Spent: 3h 10m  (was: 3h)

> 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: 3h 10m
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-07 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 07/Feb/20 16:42
Start Date: 07/Feb/20 16:42
Worklog Time Spent: 10m 
  Work Description: apilloud commented on issue #10634: [BEAM-9178] Support 
all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-583491621
 
 
   Run PreCommit_Java_Examples_Dataflow_Java11 PreCommit
 

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: 383714)
Time Spent: 3h  (was: 2h 50m)

> 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: 3h
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-07 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 07/Feb/20 16:35
Start Date: 07/Feb/20 16:35
Worklog Time Spent: 10m 
  Work Description: apilloud commented on issue #10634: [BEAM-9178] Support 
all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-583487978
 
 
   Run JavaPortabilityApiJava11 PreCommit
 

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: 383710)
Time Spent: 2h 50m  (was: 2h 40m)

> 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: 2h 50m
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-07 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 07/Feb/20 16:10
Start Date: 07/Feb/20 16:10
Worklog Time Spent: 10m 
  Work Description: apilloud commented on issue #10634: [BEAM-9178] Support 
all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-583474479
 
 
   test this please
 

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: 383697)
Time Spent: 2h 40m  (was: 2.5h)

> 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: 2h 40m
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-06 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 06/Feb/20 16:11
Start Date: 06/Feb/20 16:11
Worklog Time Spent: 10m 
  Work Description: apilloud commented on issue #10634: [BEAM-9178] Support 
all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-582979798
 
 
   Hi Jenkins, I'd like some tests please.
 

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: 382963)
Time Spent: 2.5h  (was: 2h 20m)

> 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: 2.5h
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-05 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 06/Feb/20 05:33
Start Date: 06/Feb/20 05:33
Worklog Time Spent: 10m 
  Work Description: robinyqiu commented on issue #10634: [BEAM-9178] 
Support all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-582744585
 
 
   @apilloud Could you help run precommit tests and merge this PR?
 

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: 382729)
Time Spent: 2h 20m  (was: 2h 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: 2h 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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-05 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 06/Feb/20 05:32
Start Date: 06/Feb/20 05:32
Worklog Time Spent: 10m 
  Work Description: robinyqiu commented on issue #10634: [BEAM-9178] 
Support all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-582744585
 
 
   @apilloud Could you help running precommit tests and merge this PR?
 

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: 382728)
Time Spent: 2h 10m  (was: 2h)

> 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: 2h 10m
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-05 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 06/Feb/20 05:31
Start Date: 06/Feb/20 05:31
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_r374846150
 
 

 ##
 File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/ExpressionConverter.java
 ##
 @@ -770,88 +765,34 @@ private RexNode convertResolvedFunctionCall(
   throw new UnsupportedOperationException(
   "Only support TUMBLE, HOP AND SESSION functions right now.");
   }
-} else if (functionCall.getFunction().getGroup().equals("ZetaSQL")) {
-  op =
-  
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR.get(
-  functionCall.getFunction().getName());
-
+} else if ("ZetaSQL".equals(funGroup)) {
   if (op == null) {
-throw new UnsupportedOperationException(
-"Does not support ZetaSQL function: " + 
functionCall.getFunction().getName());
+TypeKind returnType =
+
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_NAME_TO_RETURN_TYPE.get(funName);
+if (returnType != null) {
+  op =
+  SqlOperators.createSimpleSqlFunction(
+  funName, ZetaSqlUtils.zetaSqlTypeToCalciteType(returnType));
+} else {
+  throw new UnsupportedOperationException("Does not support ZetaSQL 
function: " + funName);
+}
   }
 
-  // There are different processes to handle argument conversion because 
INTERVAL is not a
-  // type in ZetaSQL.
-  if 
(FUNCTION_FAMILY_DATE_ADD.contains(functionCall.getFunction().getName())) {
-return convertTimestampAddFunction(functionCall, columnList, 
fieldList);
-  } else {
-for (ResolvedExpr expr : functionCall.getArgumentList()) {
-  operands.add(convertRexNodeFromResolvedExpr(expr, columnList, 
fieldList));
-}
+  for (ResolvedExpr expr : functionCall.getArgumentList()) {
+operands.add(convertRexNodeFromResolvedExpr(expr, columnList, 
fieldList));
   }
 } else {
-  throw new UnsupportedOperationException(
-  "Does not support function group: " + 
functionCall.getFunction().getGroup());
+  throw new UnsupportedOperationException("Does not support function 
group: " + funGroup);
 }
 
 SqlOperatorRewriter rewriter =
-
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR_REWRITER.get(
-functionCall.getFunction().getName());
+
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR_REWRITER.get(funName);
 
 if (rewriter != null) {
-  ret = rewriter.apply(rexBuilder(), operands);
+  return rewriter.apply(rexBuilder(), operands);
 } else {
-  ret = rexBuilder().makeCall(op, operands);
-}
-return ret;
-  }
-
-  private RexNode convertTimestampAddFunction(
-  ResolvedFunctionCall functionCall,
-  List columnList,
-  List fieldList) {
-
-TimeUnit unit =
-TIME_UNIT_CASTING_MAP.get(
-((ResolvedLiteral) 
functionCall.getArgumentList().get(2)).getValue().getEnumValue());
-
-if ((unit == TimeUnit.MICROSECOND) || (unit == TimeUnit.NANOSECOND)) {
 
 Review comment:
   Yeah right now it might work inconsistently. We can throw an exception 
during timestamp value conversion 
([here](https://github.com/apache/beam/blob/39c4a9fafb82dce126870a129c7848470d21006d/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlUtils.java#L186))
 if we see microsecond precision used, but I am not sure if we should do that. 
One  down side of that is we might break functions unnecessarily (e.g. 
CURRENT_TIMESTAMP). Or maybe we can leave it as it is and see if we can fully 
fix the precision problem? WDYT?
 

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: 382727)
Time Spent: 2h  (was: 1h 50m)

> 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 

[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-04 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 04/Feb/20 18:30
Start Date: 04/Feb/20 18:30
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_r374846150
 
 

 ##
 File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/ExpressionConverter.java
 ##
 @@ -770,88 +765,34 @@ private RexNode convertResolvedFunctionCall(
   throw new UnsupportedOperationException(
   "Only support TUMBLE, HOP AND SESSION functions right now.");
   }
-} else if (functionCall.getFunction().getGroup().equals("ZetaSQL")) {
-  op =
-  
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR.get(
-  functionCall.getFunction().getName());
-
+} else if ("ZetaSQL".equals(funGroup)) {
   if (op == null) {
-throw new UnsupportedOperationException(
-"Does not support ZetaSQL function: " + 
functionCall.getFunction().getName());
+TypeKind returnType =
+
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_NAME_TO_RETURN_TYPE.get(funName);
+if (returnType != null) {
+  op =
+  SqlOperators.createSimpleSqlFunction(
+  funName, ZetaSqlUtils.zetaSqlTypeToCalciteType(returnType));
+} else {
+  throw new UnsupportedOperationException("Does not support ZetaSQL 
function: " + funName);
+}
   }
 
-  // There are different processes to handle argument conversion because 
INTERVAL is not a
-  // type in ZetaSQL.
-  if 
(FUNCTION_FAMILY_DATE_ADD.contains(functionCall.getFunction().getName())) {
-return convertTimestampAddFunction(functionCall, columnList, 
fieldList);
-  } else {
-for (ResolvedExpr expr : functionCall.getArgumentList()) {
-  operands.add(convertRexNodeFromResolvedExpr(expr, columnList, 
fieldList));
-}
+  for (ResolvedExpr expr : functionCall.getArgumentList()) {
+operands.add(convertRexNodeFromResolvedExpr(expr, columnList, 
fieldList));
   }
 } else {
-  throw new UnsupportedOperationException(
-  "Does not support function group: " + 
functionCall.getFunction().getGroup());
+  throw new UnsupportedOperationException("Does not support function 
group: " + funGroup);
 }
 
 SqlOperatorRewriter rewriter =
-
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR_REWRITER.get(
-functionCall.getFunction().getName());
+
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR_REWRITER.get(funName);
 
 if (rewriter != null) {
-  ret = rewriter.apply(rexBuilder(), operands);
+  return rewriter.apply(rexBuilder(), operands);
 } else {
-  ret = rexBuilder().makeCall(op, operands);
-}
-return ret;
-  }
-
-  private RexNode convertTimestampAddFunction(
-  ResolvedFunctionCall functionCall,
-  List columnList,
-  List fieldList) {
-
-TimeUnit unit =
-TIME_UNIT_CASTING_MAP.get(
-((ResolvedLiteral) 
functionCall.getArgumentList().get(2)).getValue().getEnumValue());
-
-if ((unit == TimeUnit.MICROSECOND) || (unit == TimeUnit.NANOSECOND)) {
 
 Review comment:
   Yeah right now it might work inconsistently. We can throw an exception 
during timestamp value conversion 
([here](https://github.com/apache/beam/blob/39c4a9fafb82dce126870a129c7848470d21006d/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlUtils.java#L186))
 if we see microsecond precision used, but I am not sure if we should do that. 
One  down side of that is we might break functions unnecessarily (e.g. 
CURRENT_TIMESTAMP). Or maybe we can leave it as it is and see if we can fully 
fix the precision problem?
 

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: 381786)
Time Spent: 1h 50m  (was: 1h 40m)

> 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 

[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-04 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 04/Feb/20 18:30
Start Date: 04/Feb/20 18:30
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_r374846150
 
 

 ##
 File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/ExpressionConverter.java
 ##
 @@ -770,88 +765,34 @@ private RexNode convertResolvedFunctionCall(
   throw new UnsupportedOperationException(
   "Only support TUMBLE, HOP AND SESSION functions right now.");
   }
-} else if (functionCall.getFunction().getGroup().equals("ZetaSQL")) {
-  op =
-  
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR.get(
-  functionCall.getFunction().getName());
-
+} else if ("ZetaSQL".equals(funGroup)) {
   if (op == null) {
-throw new UnsupportedOperationException(
-"Does not support ZetaSQL function: " + 
functionCall.getFunction().getName());
+TypeKind returnType =
+
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_NAME_TO_RETURN_TYPE.get(funName);
+if (returnType != null) {
+  op =
+  SqlOperators.createSimpleSqlFunction(
+  funName, ZetaSqlUtils.zetaSqlTypeToCalciteType(returnType));
+} else {
+  throw new UnsupportedOperationException("Does not support ZetaSQL 
function: " + funName);
+}
   }
 
-  // There are different processes to handle argument conversion because 
INTERVAL is not a
-  // type in ZetaSQL.
-  if 
(FUNCTION_FAMILY_DATE_ADD.contains(functionCall.getFunction().getName())) {
-return convertTimestampAddFunction(functionCall, columnList, 
fieldList);
-  } else {
-for (ResolvedExpr expr : functionCall.getArgumentList()) {
-  operands.add(convertRexNodeFromResolvedExpr(expr, columnList, 
fieldList));
-}
+  for (ResolvedExpr expr : functionCall.getArgumentList()) {
+operands.add(convertRexNodeFromResolvedExpr(expr, columnList, 
fieldList));
   }
 } else {
-  throw new UnsupportedOperationException(
-  "Does not support function group: " + 
functionCall.getFunction().getGroup());
+  throw new UnsupportedOperationException("Does not support function 
group: " + funGroup);
 }
 
 SqlOperatorRewriter rewriter =
-
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR_REWRITER.get(
-functionCall.getFunction().getName());
+
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR_REWRITER.get(funName);
 
 if (rewriter != null) {
-  ret = rewriter.apply(rexBuilder(), operands);
+  return rewriter.apply(rexBuilder(), operands);
 } else {
-  ret = rexBuilder().makeCall(op, operands);
-}
-return ret;
-  }
-
-  private RexNode convertTimestampAddFunction(
-  ResolvedFunctionCall functionCall,
-  List columnList,
-  List fieldList) {
-
-TimeUnit unit =
-TIME_UNIT_CASTING_MAP.get(
-((ResolvedLiteral) 
functionCall.getArgumentList().get(2)).getValue().getEnumValue());
-
-if ((unit == TimeUnit.MICROSECOND) || (unit == TimeUnit.NANOSECOND)) {
 
 Review comment:
   Yeah right now it might work inconsistently. We can throw an exception 
during timestamp value conversion 
([here](https://github.com/apache/beam/blob/39c4a9fafb82dce126870a129c7848470d21006d/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlUtils.java#L186))
 if we see microsecond precision used, but I am not sure if we should do that. 
One  down side of that is we might break functions unnecessarily (e.g. 
CURRENT_TIMESTAMP). Or maybe we can leave it as it is and see if we can fix the 
precision problem at once?
 

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: 381785)
Time Spent: 1h 40m  (was: 1.5h)

> 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 

[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-04 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 04/Feb/20 18:24
Start Date: 04/Feb/20 18:24
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_r374842900
 
 

 ##
 File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/ExpressionConverter.java
 ##
 @@ -770,88 +765,34 @@ private RexNode convertResolvedFunctionCall(
   throw new UnsupportedOperationException(
   "Only support TUMBLE, HOP AND SESSION functions right now.");
   }
-} else if (functionCall.getFunction().getGroup().equals("ZetaSQL")) {
-  op =
-  
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR.get(
-  functionCall.getFunction().getName());
-
+} else if ("ZetaSQL".equals(funGroup)) {
   if (op == null) {
-throw new UnsupportedOperationException(
-"Does not support ZetaSQL function: " + 
functionCall.getFunction().getName());
+TypeKind returnType =
+
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_NAME_TO_RETURN_TYPE.get(funName);
 
 Review comment:
   Great suggestion! Removing the manual map simplifies the code quite a lot.
 

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: 381783)
Time Spent: 1.5h  (was: 1h 20m)

> 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: 1.5h
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-04 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/BEAM-9178?focusedWorklogId=381782=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 https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#timestamp_add;>
+   * BQ TIMESTAMP_ADD function 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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-03 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


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

 ##
 File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/ExpressionConverter.java
 ##
 @@ -770,88 +765,34 @@ private RexNode convertResolvedFunctionCall(
   throw new UnsupportedOperationException(
   "Only support TUMBLE, HOP AND SESSION functions right now.");
   }
-} else if (functionCall.getFunction().getGroup().equals("ZetaSQL")) {
-  op =
-  
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR.get(
-  functionCall.getFunction().getName());
-
+} else if ("ZetaSQL".equals(funGroup)) {
   if (op == null) {
-throw new UnsupportedOperationException(
-"Does not support ZetaSQL function: " + 
functionCall.getFunction().getName());
+TypeKind returnType =
+
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_NAME_TO_RETURN_TYPE.get(funName);
+if (returnType != null) {
+  op =
+  SqlOperators.createSimpleSqlFunction(
+  funName, ZetaSqlUtils.zetaSqlTypeToCalciteType(returnType));
+} else {
+  throw new UnsupportedOperationException("Does not support ZetaSQL 
function: " + funName);
+}
   }
 
-  // There are different processes to handle argument conversion because 
INTERVAL is not a
-  // type in ZetaSQL.
-  if 
(FUNCTION_FAMILY_DATE_ADD.contains(functionCall.getFunction().getName())) {
-return convertTimestampAddFunction(functionCall, columnList, 
fieldList);
-  } else {
-for (ResolvedExpr expr : functionCall.getArgumentList()) {
-  operands.add(convertRexNodeFromResolvedExpr(expr, columnList, 
fieldList));
-}
+  for (ResolvedExpr expr : functionCall.getArgumentList()) {
+operands.add(convertRexNodeFromResolvedExpr(expr, columnList, 
fieldList));
   }
 } else {
-  throw new UnsupportedOperationException(
-  "Does not support function group: " + 
functionCall.getFunction().getGroup());
+  throw new UnsupportedOperationException("Does not support function 
group: " + funGroup);
 }
 
 SqlOperatorRewriter rewriter =
-
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR_REWRITER.get(
-functionCall.getFunction().getName());
+
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR_REWRITER.get(funName);
 
 if (rewriter != null) {
-  ret = rewriter.apply(rexBuilder(), operands);
+  return rewriter.apply(rexBuilder(), operands);
 } else {
-  ret = rexBuilder().makeCall(op, operands);
-}
-return ret;
-  }
-
-  private RexNode convertTimestampAddFunction(
-  ResolvedFunctionCall functionCall,
-  List columnList,
-  List fieldList) {
-
-TimeUnit unit =
-TIME_UNIT_CASTING_MAP.get(
-((ResolvedLiteral) 
functionCall.getArgumentList().get(2)).getValue().getEnumValue());
-
-if ((unit == TimeUnit.MICROSECOND) || (unit == TimeUnit.NANOSECOND)) {
 
 Review comment:
   This 'works' now but it is still not supported in our type system, so it 
might work inconsistently. (Microseconds will be dropped once we are out of 
ZetaSQLCalc.) Should we be making sure ZetaSQLCalc has the correct hooks to 
error if the user interacts with microsecond precision values?
   cc: @kennknowles 
 

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: 381264)
Time Spent: 1h 10m  (was: 1h)

> 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 10m
>  Remaining Estimate: 0h
>
> Support *all* TIMESTAMP functions defined in ZetaSQL (BigQuery Standard SQL). 
> See the full list of functions below:
> 

[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-03 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


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

 ##
 File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/ExpressionConverter.java
 ##
 @@ -52,7 +51,6 @@
 import com.google.zetasql.resolvedast.ResolvedNodes.ResolvedOrderByScan;
 import com.google.zetasql.resolvedast.ResolvedNodes.ResolvedParameter;
 import com.google.zetasql.resolvedast.ResolvedNodes.ResolvedProjectScan;
-import io.grpc.Status;
 
 Review comment:
   :+1: Thanks. This actually adds quite a bit of complexity elsewhere.
 

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: 381263)
Time Spent: 1h  (was: 50m)

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


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-03 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


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

 ##
 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 https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#timestamp_add;>
+   * BQ TIMESTAMP_ADD function 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:
   s/parse/unparse/
 

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: 381261)
Time Spent: 50m  (was: 40m)

> 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: 50m
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-03 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


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

 ##
 File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/ExpressionConverter.java
 ##
 @@ -770,88 +765,34 @@ private RexNode convertResolvedFunctionCall(
   throw new UnsupportedOperationException(
   "Only support TUMBLE, HOP AND SESSION functions right now.");
   }
-} else if (functionCall.getFunction().getGroup().equals("ZetaSQL")) {
-  op =
-  
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_TO_CALCITE_SQL_OPERATOR.get(
-  functionCall.getFunction().getName());
-
+} else if ("ZetaSQL".equals(funGroup)) {
   if (op == null) {
-throw new UnsupportedOperationException(
-"Does not support ZetaSQL function: " + 
functionCall.getFunction().getName());
+TypeKind returnType =
+
SqlStdOperatorMappingTable.ZETASQL_FUNCTION_NAME_TO_RETURN_TYPE.get(funName);
 
 Review comment:
   Manually maintaining this list seems like no fun. What about using 
`functionCall.getSignature().getResultType().getType()`?
 

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: 381262)

> 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: 50m
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-03 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 03/Feb/20 23:24
Start Date: 03/Feb/20 23:24
Worklog Time Spent: 10m 
  Work Description: apilloud commented on issue #10634: [BEAM-9178] Support 
all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-581668221
 
 
   I'm guessing you didn't mean to create a merge commit here?
 

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: 381245)
Time Spent: 40m  (was: 0.5h)

> 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: 40m
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-02-03 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 03/Feb/20 21:13
Start Date: 03/Feb/20 21:13
Worklog Time Spent: 10m 
  Work Description: robinyqiu commented on issue #10634: [BEAM-9178] 
Support all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-581620899
 
 
   Friendly ping.
 

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: 381185)
Time Spent: 0.5h  (was: 20m)

> 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: 0.5h
>  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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-01-28 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 28/Jan/20 21:52
Start Date: 28/Jan/20 21:52
Worklog Time Spent: 10m 
  Work Description: robinyqiu commented on issue #10634: [BEAM-9178] 
Support all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-579474737
 
 
   Factored out the controversial parts that you mentioned. Now we don't 
support extracting or truncating "week with weekdays" part (I think this is 
fine).
   
   PR is ready for review now.
 

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: 378496)
Time Spent: 20m  (was: 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: 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)


[jira] [Work logged] (BEAM-9178) Support ZetaSQL TIMESTAMP functions in BeamSQL

2020-01-23 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot logged work on BEAM-9178:


Author: ASF GitHub Bot
Created on: 23/Jan/20 18:53
Start Date: 23/Jan/20 18:53
Worklog Time Spent: 10m 
  Work Description: apilloud commented on issue #10634: [BEAM-9178] Support 
all ZetaSQL TIMESTAMP functions
URL: https://github.com/apache/beam/pull/10634#issuecomment-577822265
 
 
   On breaking this up: There are a few cleanups (ImmutableList.of fixes, 
renaming `TimeStamp` to `Timestamp`) and 73eaef8 `Fix 
unparseFunctionsUsingInterval()` that can be pulled into their own PRs and go 
in immediately, those look to be about 25% of this change.
   
   I think  also be worth pulling the `BeamZetaSqlDateTimePart` stuff (in 
67ef67d `Support EXTRACT and TIMESTAMP_TRUNC function`) into a separate change. 
We want to eventually support `BeamCalcRel` when possible, this introduces 
quite a few regressions that I expect will be controversial.
 

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: 376433)
Remaining Estimate: 0h
Time Spent: 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: 10m
>  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)