robinyqiu commented on a change in pull request #12174:
URL: https://github.com/apache/beam/pull/12174#discussion_r455233394



##########
File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/ExpressionConverter.java
##########
@@ -805,6 +807,24 @@ private RexNode convertSimpleValueToRexNode(TypeKind kind, 
Value value) {
                 .makeLiteral(
                     value.getStringValue(), 
typeFactory().createSqlType(SqlTypeName.VARCHAR), true);
         break;
+      case TYPE_NUMERIC:
+        // Cannot simply call makeExactLiteral() for ZetaSQL NUMERIC type 
because later it will be
+        // unparsed to the string representation of the BigDecimal itself 
(e.g. "SELECT NUMERIC '0'"
+        // will be unparsed to "SELECT 0E-9"), and Calcite does not allow 
customize unparsing of
+        // SqlNumericLiteral. So we create a wrapper function here such that 
we can later recognize
+        // it and customize its unparsing in BeamBigQuerySqlDialect.
+        ret =
+            rexBuilder()
+                .makeCall(
+                    SqlOperators.createSimpleSqlFunction(
+                        "numeric_literal", 
ZetaSqlCalciteTranslationUtils.toCalciteTypeName(kind)),

Review comment:
       Zijie, here you can refer to `NUMERIC_LITERAL_FUNCTION` (of course you 
need to make it public) you defined in the other file.




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


Reply via email to