DonnyZone commented on a change in pull request #1216: [CALCITE-3072] Generate 
right SQL for FLOOR&SUBSTRING functions in SparkSqlDialect
URL: https://github.com/apache/calcite/pull/1216#discussion_r285325702
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/sql/dialect/SparkSqlDialect.java
 ##########
 @@ -55,6 +70,32 @@ public SparkSqlDialect(SqlDialect.Context context) {
       SqlNode fetch) {
     unparseFetchUsingLimit(writer, offset, fetch);
   }
+
+  @Override public void unparseCall(SqlWriter writer, SqlCall call,
+      int leftPrec, int rightPrec) {
+    if (call.getOperator() == SqlStdOperatorTable.SUBSTRING) {
+      SqlUtil.unparseFunctionSyntax(SPARKSQL_SUBSTRING, writer, call);
+    } else {
+      switch (call.getKind()) {
+      case FLOOR:
+        if (call.operandCount() != 2) {
+          super.unparseCall(writer, call, leftPrec, rightPrec);
 
 Review comment:
   Done. This rewriting logic is similar to that in `PostgresqlSqlDialect` for 
[CALCITE-1798](https://issues.apache.org/jira/browse/CALCITE-1798). Add a test 
case for one operand.

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


With regards,
Apache Git Services

Reply via email to