morningman commented on a change in pull request #6102:
URL: https://github.com/apache/incubator-doris/pull/6102#discussion_r699283182



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -3096,6 +3104,48 @@ public void createTableLike(CreateTableLikeStmt stmt) 
throws DdlException {
         }
     }
 
+    public void createTableAsSelect(CreateTableAsSelectStmt stmt) throws 
DdlException {
+        try {
+            QueryStmt tmpStmt = stmt.getQueryStmt().clone();
+            List<String> columnNames = stmt.getColumnNames();
+            CreateTableStmt createTableStmt = stmt.getCreateTableStmt();
+            Analyzer dummyRootAnalyzer = new Analyzer(this, 
ConnectContext.get());
+            tmpStmt.analyze(dummyRootAnalyzer);
+            // Check columnNames
+            if (columnNames != null && columnNames.size() != 
tmpStmt.getColLabels().size()) {
+                ErrorReport.report(ErrorCode.ERR_COL_NUMBER_NOT_MATCH);
+            } else {
+                for (int i = 0; i < tmpStmt.getColLabels().size(); ++i) {
+                    String name;
+                    Expr expr = tmpStmt.getResultExprs().get(i);
+                    if (columnNames != null) {
+                        name = columnNames.get(i);
+                    } else {
+                        name = expr.toColumnLabel().replaceAll("'", "");

Review comment:
       How about decimal type

##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -3096,6 +3104,48 @@ public void createTableLike(CreateTableLikeStmt stmt) 
throws DdlException {
         }
     }
 
+    public void createTableAsSelect(CreateTableAsSelectStmt stmt) throws 
DdlException {
+        try {
+            QueryStmt tmpStmt = stmt.getQueryStmt().clone();

Review comment:
       Why not put this logic in `analyze()` of `CreateTableAsSelectStmt`?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to