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 2021/09/06 02:40:39 UTC
[GitHub] [incubator-doris] stalary commented on a change in pull request #6102: WIP: Support create table as select
stalary commented on a change in pull request #6102:
URL: https://github.com/apache/incubator-doris/pull/6102#discussion_r702527861
##########
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:
Handle by reporting errors
--
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: commits-unsubscribe@doris.apache.org
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