|
25 | 25 | import org.apache.doris.common.DdlException; |
26 | 26 | import org.apache.doris.common.UserException; |
27 | 27 | import org.apache.doris.datasource.CatalogIf; |
| 28 | +import org.apache.doris.datasource.ExternalObjectLog; |
28 | 29 | import org.apache.doris.datasource.ExternalTable; |
29 | 30 | import org.apache.doris.nereids.trees.expressions.Expression; |
30 | 31 | import org.apache.doris.nereids.trees.plans.PlanType; |
@@ -104,6 +105,7 @@ public void run(ConnectContext ctx, StmtExecutor executor) throws Exception { |
104 | 105 |
|
105 | 106 | action.validate(tableNameInfo, ctx.getCurrentUserIdentity()); |
106 | 107 | ResultSet resultSet = action.execute(table); |
| 108 | + logRefreshTable(table); |
107 | 109 | if (resultSet != null) { |
108 | 110 | executor.sendResultSet(resultSet); |
109 | 111 | } |
@@ -141,4 +143,25 @@ public Optional<PartitionNamesInfo> getPartitionNamesInfo() { |
141 | 143 | public Optional<Expression> getWhereCondition() { |
142 | 144 | return whereCondition; |
143 | 145 | } |
| 146 | + |
| 147 | + /** |
| 148 | + * Log refresh table to make follow fe metadata cache refresh. |
| 149 | + * |
| 150 | + * @param table the table to log |
| 151 | + * @throws UserException if the table type is not supported |
| 152 | + */ |
| 153 | + private void logRefreshTable(TableIf table) throws UserException { |
| 154 | + if (table instanceof ExternalTable) { |
| 155 | + ExternalTable externalTable = (ExternalTable) table; |
| 156 | + Env.getCurrentEnv().getEditLog() |
| 157 | + .logRefreshExternalTable( |
| 158 | + ExternalObjectLog.createForRefreshTable( |
| 159 | + externalTable.getCatalog().getId(), |
| 160 | + externalTable.getDbName(), |
| 161 | + externalTable.getName())); |
| 162 | + } else { |
| 163 | + // support more table in future |
| 164 | + throw new UserException("Unsupported table type: " + table.getClass().getName() + " for refresh table"); |
| 165 | + } |
| 166 | + } |
144 | 167 | } |
0 commit comments