zratkai commented on code in PR #5541:
URL: https://github.com/apache/hive/pull/5541#discussion_r1904349394


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java:
##########
@@ -16089,7 +16097,26 @@ protected void 
addPartitionColsToInsert(List<FieldSchema> partCols,
       rewrittenQueryStr.append(")");
     }
   }
-
+  
+  private String getSortOrderJson(ASTNode ast) {
+    List<SortFieldDesc> sortFieldDescList = new ArrayList<>();
+    SortFields sortFields = new SortFields(sortFieldDescList);
+    for (int i = 0; i < ast.getChildCount(); i++) {
+      ASTNode child = (ASTNode) ast.getChild(i);
+      SortFieldDesc.SortDirection sortDirection = child.getToken()
+          .getType() == HiveParser.TOK_TABSORTCOLNAMEDESC ? 
SortFieldDesc.SortDirection.DESC : SortFieldDesc.SortDirection.ASC;
+      child = (ASTNode) child.getChild(0);
+      String name = 
unescapeIdentifier(child.getChild(0).getText()).toLowerCase();
+      SortFieldDesc.NullOrder nullOrder = child.getToken().getType() == 
HiveParser.TOK_NULLS_FIRST ? SortFieldDesc.NullOrder.NULLS_FIRST : 
SortFieldDesc.NullOrder.NULLS_LAST;
+      sortFieldDescList.add(new SortFieldDesc(name, sortDirection, nullOrder));
+    }
+    try {
+      return jsonObjectMapper.writeValueAsString(sortFields);
+    } catch (JsonProcessingException e) {
+      return null;
+    }
+    //return new JSONObject().put("fields", new 
JSONArray(sortFields.stream().map(SortFieldDesc::toString).collect(Collectors.toList()))).toString();
+  }
   @Override

Review Comment:
   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.

To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to