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 2020/04/23 11:39:20 UTC

[GitHub] [incubator-doris] EmmyMiao87 commented on a change in pull request #3378: Forbidden correlated having clause

EmmyMiao87 commented on a change in pull request #3378:
URL: https://github.com/apache/incubator-doris/pull/3378#discussion_r413742426



##########
File path: fe/src/main/java/org/apache/doris/analysis/BaseViewStmt.java
##########
@@ -109,33 +112,37 @@ protected void createColumnAndViewDefs(Analyzer analyzer) throws AnalysisExcepti
         }
 
         // format view def string
-        originalViewDef = viewDefStmt.toSql();
+        String lowerCaseOriginSql = getOriginSql().toLowerCase();
+
+        originalViewDef = lowerCaseOriginSql.substring(lowerCaseOriginSql.indexOf(KW_AS) + 3);
+        LOG.debug("origin view def sql is {}", originalViewDef);
 
         if (cols == null) {
             inlineViewDef = originalViewDef;
+            LOG.debug("inline view def sql is {}", inlineViewDef);
             return;
         }
 
         Analyzer tmpAnalyzer = new Analyzer(analyzer);
         List<String> colNames = cols.stream().map(c -> c.getColName()).collect(Collectors.toList());
         cloneStmt.substituteSelectList(tmpAnalyzer, colNames);
-        inlineViewDef = cloneStmt.toSql();
-
-//        StringBuilder sb = new StringBuilder();
-//        sb.append("SELECT ");
-//        for (int i = 0; i < finalCols.size(); ++i) {
-//            if (i != 0) {
-//                sb.append(", ");
-//            }
-//            String colRef = viewDefStmt.getColLabels().get(i);
-//            if (!colRef.startsWith("`")) {
-//                colRef = "`" + colRef + "`";
-//            }
-//            String colAlias = finalCols.get(i).getName();
-//            sb.append(String.format("`%s`.%s AS `%s`", tableName.getTbl(), colRef, colAlias));
-//        }
-//        sb.append(String.format(" FROM (%s) %s", originalViewDef, tableName.getTbl()));
-//        inlineViewDef = sb.toString();
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("SELECT ");
+        for (int i = 0; i < colNames.size(); ++i) {
+            if (i != 0) {
+                sb.append(", ");
+            }
+            String colRef = viewDefStmt.getColLabels().get(i);
+            if (!colRef.startsWith("`")) {
+                colRef = "`" + colRef + "`";
+            }
+            String colAlias = colNames.get(i);
+            sb.append(String.format("`%s`.%s AS `%s`", tableName.getTbl(), colRef, colAlias));

Review comment:
       This change has been removed.




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



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