xy720 commented on a change in pull request #2641: CreateViewStmt/AlterViewStmt
support cte and fix bug
URL: https://github.com/apache/incubator-doris/pull/2641#discussion_r363181193
##########
File path: fe/src/main/java/org/apache/doris/analysis/BaseViewStmt.java
##########
@@ -113,27 +113,21 @@ protected void createColumnAndViewDefs(Analyzer
analyzer) throws AnalysisExcepti
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 < columnNames.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 < 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));
Review comment:
It is work. Because the analyze is happen at before. What is doing here is
just to wrap another sql outside the previous analyzed 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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]