ZijieSong946 commented on a change in pull request #12174:
URL: https://github.com/apache/beam/pull/12174#discussion_r455234860
##########
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:
OK. Done.
----------------------------------------------------------------
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]