You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2019/12/04 12:17:48 UTC

[GitHub] [incubator-doris] imay commented on a change in pull request #2380: add where/orderby/limit after “SHOW ALTER TABLE COLUMN“ syntax

imay commented on a change in pull request #2380: add where/orderby/limit after “SHOW ALTER TABLE COLUMN“ syntax
URL: https://github.com/apache/incubator-doris/pull/2380#discussion_r353703490
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/analysis/ShowAlterStmt.java
 ##########
 @@ -121,11 +221,30 @@ private void handleShowAlterTable(Analyzer analyzer) throws AnalysisException, U
     @Override
     public String toSql() {
         StringBuilder sb = new StringBuilder();
-        sb.append("SHOW ALTER ").append(type.name()).append(" ");
+        sb.append("SHOW ALTER TABLE ").append(type.name()).append(" ");
         if (!Strings.isNullOrEmpty(dbName)) {
             sb.append("FROM `").append(dbName).append("`");
         }
+        if (whereClause != null) {
+            sb.append(" WHERE ").append(whereClause.toSql());
+        }
+        // Order By clause
+        if (orderByElements != null) {
+            sb.append(" ORDER BY ");
+            for (int i = 0; i < orderByElements.size(); ++i) {
+                sb.append(orderByElements.get(i).getExpr().toSql());
+                sb.append((orderByElements.get(i).getIsAsc()) ? " ASC" : " DESC");
+                sb.append((i + 1 != orderByElements.size()) ? ", " : "");
+            }
+        }
 
+        if (limitElement != null && limitElement.hasLimit()) {
+            sb.append(" LIMIT ").append(limitElement.getLimit());
+            if (limitElement.hasOffset()) {
+                sb.append(" OFFSET ").append(limitElement.getOffset());
+            }
 
 Review comment:
   why not sb.append(limitElement.toSql())

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

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org