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 2022/05/08 08:04:43 UTC

[GitHub] [incubator-doris] morrySnow commented on a diff in pull request #9391: [Feature] show create materialized view

morrySnow commented on code in PR #9391:
URL: https://github.com/apache/incubator-doris/pull/9391#discussion_r867451804


##########
fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java:
##########
@@ -2178,4 +2182,25 @@ private void handleAdminDiagnoseTablet() {
         resultSet = new ShowResultSet(showMetaData, resultRowSet);
     }
 
+    private void handleShowCreateMaterializedView() throws AnalysisException {
+        List<List<String>> resultRowSet = new ArrayList<>();
+        ShowCreateMaterializedViewStmt showStmt = (ShowCreateMaterializedViewStmt) stmt;
+        Database db = Catalog.getCurrentCatalog().getDbOrAnalysisException(showStmt.getTableName().getDb());
+        Table table = db.getTableOrAnalysisException(showStmt.getTableName().getTbl());
+        OlapTable baseTable = ((OlapTable) table);

Review Comment:
   should check table type before cast



##########
fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java:
##########
@@ -2178,4 +2182,25 @@ private void handleAdminDiagnoseTablet() {
         resultSet = new ShowResultSet(showMetaData, resultRowSet);
     }
 
+    private void handleShowCreateMaterializedView() throws AnalysisException {
+        List<List<String>> resultRowSet = new ArrayList<>();
+        ShowCreateMaterializedViewStmt showStmt = (ShowCreateMaterializedViewStmt) stmt;
+        Database db = Catalog.getCurrentCatalog().getDbOrAnalysisException(showStmt.getTableName().getDb());
+        Table table = db.getTableOrAnalysisException(showStmt.getTableName().getTbl());
+        OlapTable baseTable = ((OlapTable) table);
+        Long indexIdByName = baseTable.getIndexIdByName(showStmt.getMvName());
+        MaterializedIndexMeta meta = baseTable.getIndexMetaByIndexId(indexIdByName);
+        if (meta == null || meta.getDefineStmt() == null) {

Review Comment:
   ```suggestion
           if (meta != null && meta.getDefineStmt() != null) {
               String originStmt = meta.getDefineStmt().originStmt;
               List<String> data = new ArrayList<>();
               data.add(showStmt.getTableName().getTbl());
               data.add(showStmt.getMvName());
               data.add(originStmt);
               resultRowSet.add(data);
           }
           resultSet = new ShowResultSet(showStmt.getMetaData(), resultRowSet);
   ```



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