You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/07/05 08:48:54 UTC

[GitHub] [calcite] jinxing64 commented on a change in pull request #1285: [CALCITE-3154] RelToSqlConverter generated Nulls Last and Nulls First when convert RexOver to sql using MysqlSqlDialect.

jinxing64 commented on a change in pull request #1285: [CALCITE-3154] RelToSqlConverter generated Nulls Last and Nulls First when convert RexOver to sql using MysqlSqlDialect.
URL: https://github.com/apache/calcite/pull/1285#discussion_r300592380
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java
 ##########
 @@ -795,6 +795,29 @@ void addOrderItem(List<SqlNode> orderByList, RelFieldCollation field) {
       orderByList.add(toSql(field));
     }
 
+
+    void addOrderItem(List<SqlNode> orderByList, RexProgram program, RexFieldCollation field) {
+      SqlNode node = toSql(program, field.left);
+      SqlNode nullDirectionNode = null;
+      if (field.getNullDirection() != RelFieldCollation.NullDirection.UNSPECIFIED) {
+        final boolean first =
+                  field.getNullDirection() == RelFieldCollation.NullDirection.FIRST;
+        nullDirectionNode = dialect.emulateNullDirection(
+                node, first, field.getDirection().isDescending());
+      }
+      if (nullDirectionNode != null) {
+        orderByList.add(nullDirectionNode);
+        switch (field.getDirection()) {
+        case DESCENDING:
+        case STRICTLY_DESCENDING:
+          node = SqlStdOperatorTable.DESC.createCall(POS, node);
 
 Review comment:
   From code style, I'd prefer a  `default` case here and doc 'do-nothing'

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services