quxiucheng commented on a change in pull request #1568: [CALCITE-3486] In JDBC 
adapter, when generating ROW value expression, generates the ROW keyword only 
if the dialect allows it (quxiucheng)
URL: https://github.com/apache/calcite/pull/1568#discussion_r345179974
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/sql/SqlDialect.java
 ##########
 @@ -448,6 +448,31 @@ public void unparseCall(SqlWriter writer, SqlCall call, 
int leftPrec,
     call.getOperator().unparse(writer, call, leftPrec, rightPrec);
   }
 
+  public void unparseRow(SqlWriter writer,
+      SqlCall call, int leftPrec,  int rightPrec) {
+    if (getConformance().allowExplicitRowValueConstructor()) {
+      SqlUtil.unparseFunctionSyntax(call.getOperator(), writer, call);
+    } else {
+      if (" ".equals(call.getOperator().getName())) {
+        writer.print(call.getOperator().getName());
+      }
+      if (writer.isAlwaysUseParentheses()) {
+        for (SqlNode operand : call.getOperandList()) {
+          writer.sep(",");
 
 Review comment:
   This `isAlwaysUseParentheses` parameter will link operations with 
parentheses.
   For example ,
   `(a + b) * c`.The fully-parenthesized expression, `((a + b) * c)`
   
   If this parameter is in the `SqlRowOperator`. There will be extra parentheses
   For example,
   `isAlwaysUseParentheses=true` and `allowExplicitRowValueConstructor=false`
   
   input expression:
   `insert into emp valuse (1,'a')`
   
   unparse result:
   `insert into emp valuse ((1,'a'))`
   
   I think this is a wrong SQL.

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