Co-authored-by: Murphy <96611012+murphyatwork@users.noreply.github.com>
This commit is contained in:
parent
0649cfb7a8
commit
d82390e5a2
|
|
@ -101,7 +101,6 @@ public class AnalyzeStatusSystemTable extends SystemTable {
|
|||
}
|
||||
}
|
||||
TAnalyzeStatusItem item = new TAnalyzeStatusItem();
|
||||
itemList.add(item);
|
||||
item.setCatalog_name("");
|
||||
item.setDatabase_name("");
|
||||
item.setTable_name("");
|
||||
|
|
@ -118,6 +117,7 @@ public class AnalyzeStatusSystemTable extends SystemTable {
|
|||
continue;
|
||||
}
|
||||
} catch (MetaNotFoundException ignored) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String columnStr = "ALL";
|
||||
|
|
@ -135,6 +135,7 @@ public class AnalyzeStatusSystemTable extends SystemTable {
|
|||
item.setEnd_time(DateUtils.formatDateTimeUnix(analyze.getEndTime()));
|
||||
item.setProperties(analyze.getProperties() == null ? "{}" : analyze.getProperties().toString());
|
||||
item.setReason(analyze.getReason());
|
||||
itemList.add(item);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.google.common.collect.Maps;
|
|||
import com.starrocks.analysis.TableName;
|
||||
import com.starrocks.catalog.Database;
|
||||
import com.starrocks.catalog.Table;
|
||||
import com.starrocks.catalog.system.information.AnalyzeStatusSystemTable;
|
||||
import com.starrocks.common.util.UUIDUtil;
|
||||
import com.starrocks.journal.JournalEntity;
|
||||
import com.starrocks.persist.OperationType;
|
||||
|
|
@ -28,9 +29,11 @@ import com.starrocks.server.GlobalStateMgr;
|
|||
import com.starrocks.sql.common.MetaUtils;
|
||||
import com.starrocks.sql.optimizer.statistics.CachedStatisticStorage;
|
||||
import com.starrocks.sql.plan.ConnectorPlanTestBase;
|
||||
import com.starrocks.thrift.TAnalyzeStatusReq;
|
||||
import com.starrocks.thrift.TUniqueId;
|
||||
import com.starrocks.transaction.InsertTxnCommitAttachment;
|
||||
import com.starrocks.transaction.TransactionState;
|
||||
import com.starrocks.utframe.StarRocksAssert;
|
||||
import com.starrocks.utframe.UtFrameUtils;
|
||||
import mockit.Mock;
|
||||
import mockit.MockUp;
|
||||
|
|
@ -319,4 +322,32 @@ public class AnalyzeMgrTest {
|
|||
transactionState.setTxnCommitAttachment(new InsertTxnCommitAttachment(0));
|
||||
GlobalStateMgr.getCurrentState().getAnalyzeMgr().updateLoadRows(transactionState);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuery() throws Exception {
|
||||
final String dbName = "db_analyze_status";
|
||||
StarRocksAssert starRocksAssert = new StarRocksAssert(connectContext);
|
||||
|
||||
starRocksAssert
|
||||
.withDatabase(dbName)
|
||||
.useDatabase(dbName)
|
||||
.withTable("create table t1 (c1 int, c2 int) properties('replication_num'='1')");
|
||||
UtFrameUtils.mockDML();
|
||||
starRocksAssert.getCtx().executeSql("insert into t1 values (1,1)");
|
||||
starRocksAssert.getCtx().executeSql("analyze table t1 with sync mode");
|
||||
|
||||
// Add the analyze status but drop the table
|
||||
Database db = starRocksAssert.getDb(dbName);
|
||||
Table table = starRocksAssert.getTable(dbName, "t1");
|
||||
AnalyzeStatus analyzeStatus = new NativeAnalyzeStatus(100,
|
||||
db.getId(), table.getId(),
|
||||
ImmutableList.of("c1", "c2"), StatsConstants.AnalyzeType.FULL,
|
||||
StatsConstants.ScheduleType.ONCE, Maps.newHashMap(), LocalDateTime.now());
|
||||
GlobalStateMgr.getCurrentState().getAnalyzeMgr().addAnalyzeStatus(analyzeStatus);
|
||||
starRocksAssert.dropDatabase(dbName).withDatabase(dbName);
|
||||
|
||||
TAnalyzeStatusReq request = new TAnalyzeStatusReq();
|
||||
AnalyzeStatusSystemTable.query(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue