Skip to content

Commit 51548db

Browse files
branch-4.0: [fix](iceberg) Add FE refresh logging after ALTER TABLE … EXECUTE #58355 (#58379)
Cherry-picked from #58355 Co-authored-by: Socrates <[email protected]>
1 parent 2cae548 commit 51548db

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ExecuteActionCommand.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.doris.common.DdlException;
2626
import org.apache.doris.common.UserException;
2727
import org.apache.doris.datasource.CatalogIf;
28+
import org.apache.doris.datasource.ExternalObjectLog;
2829
import org.apache.doris.datasource.ExternalTable;
2930
import org.apache.doris.nereids.trees.expressions.Expression;
3031
import org.apache.doris.nereids.trees.plans.PlanType;
@@ -104,6 +105,7 @@ public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
104105

105106
action.validate(tableNameInfo, ctx.getCurrentUserIdentity());
106107
ResultSet resultSet = action.execute(table);
108+
logRefreshTable(table);
107109
if (resultSet != null) {
108110
executor.sendResultSet(resultSet);
109111
}
@@ -141,4 +143,25 @@ public Optional<PartitionNamesInfo> getPartitionNamesInfo() {
141143
public Optional<Expression> getWhereCondition() {
142144
return whereCondition;
143145
}
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+
}
144167
}

regression-test/suites/external_table_p0/iceberg/action/test_iceberg_rewrite_data_files_where_conditions.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ suite("test_iceberg_rewrite_data_files_where_conditions", "p0,external,doris,ext
7171
// Test 1: Rewrite without WHERE condition (baseline - should rewrite files)
7272
logger.info("Test 1: Rewrite without WHERE condition (baseline)")
7373

74+
def totalRecordsBaselineBefore = sql """SELECT COUNT(*) FROM ${table_baseline}"""
75+
logger.info("Baseline table record count before rewrite: ${totalRecordsBaselineBefore[0][0]}")
76+
assertTrue(totalRecordsBaselineBefore[0][0] == 30, "Total record count should be 30 before baseline test")
77+
7478
def rewriteResultNoWhere = sql """
7579
ALTER TABLE ${catalog_name}.${db_name}.${table_baseline}
7680
EXECUTE rewrite_data_files(
@@ -90,6 +94,7 @@ suite("test_iceberg_rewrite_data_files_where_conditions", "p0,external,doris,ext
9094

9195
// Verify data integrity
9296
def totalRecords1 = sql """SELECT COUNT(*) FROM ${table_baseline}"""
97+
logger.info("Total record count after baseline test: ${totalRecords1[0][0]}")
9398
assertTrue(totalRecords1[0][0] == 30, "Total record count should be 30 after baseline test")
9499

95100
// Test 2: Rewrite with WHERE condition matching subset of data

0 commit comments

Comments
 (0)