Skip to content

Commit 88ffb18

Browse files
[UT] fix unstable fe ut testLogicalOlapTableScanPartitionPrune1 (backport #64724) (#64758)
Signed-off-by: stephen <[email protected]> Co-authored-by: stephen <[email protected]>
1 parent 9855f58 commit 88ffb18

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

fe/fe-core/src/test/java/com/starrocks/sql/optimizer/statistics/StatisticsCalculatorTest.java

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@
5353
import com.starrocks.sql.plan.ConnectorPlanTestBase;
5454
import com.starrocks.utframe.StarRocksAssert;
5555
import com.starrocks.utframe.UtFrameUtils;
56-
import mockit.Expectations;
5756
import mockit.Mock;
5857
import mockit.MockUp;
59-
import mockit.Mocked;
6058
import org.junit.jupiter.api.AfterEach;
6159
import org.junit.jupiter.api.Assertions;
6260
import org.junit.jupiter.api.BeforeAll;
@@ -391,24 +389,24 @@ public List<ColumnStatistic> getColumnStatistics(Table table, List<String> colum
391389
}
392390

393391
@Test
394-
public void testLogicalOlapTableScanPartitionPrune1(@Mocked CachedStatisticStorage cachedStatisticStorage) {
392+
public void testLogicalOlapTableScanPartitionPrune1() {
395393
FeConstants.runningUnitTest = true;
396394
ColumnRefOperator idDate = columnRefFactory.create("id_date", Type.DATE, true);
397395

398396
GlobalStateMgr globalStateMgr = connectContext.getGlobalStateMgr();
399397
Table table = globalStateMgr.getLocalMetastore().getDb("statistics_test").getTable("test_all_type");
400398

401-
new Expectations() {
402-
{
403-
cachedStatisticStorage.getColumnStatistics(table, Lists.newArrayList("id_date"));
404-
result = new ColumnStatistic(0, Utils.getLongFromDateTime(LocalDateTime.of(2014, 12, 01, 0, 0, 0)),
405-
0, 0, 30);
406-
minTimes = 0;
407-
408-
cachedStatisticStorage.getColumnStatistic(table, "id_date");
409-
result = new ColumnStatistic(0, Utils.getLongFromDateTime(LocalDateTime.of(2014, 12, 01, 0, 0, 0)),
410-
0, 0, 30);
411-
minTimes = 0;
399+
new MockUp<CachedStatisticStorage>() {
400+
@Mock
401+
public List<ColumnStatistic> getColumnStatistics(Table table, List<String> columns) {
402+
return List.of(new ColumnStatistic(0, Utils.getLongFromDateTime(
403+
LocalDateTime.of(2014, 12, 01, 0, 0, 0)), 0, 0, 30));
404+
}
405+
406+
@Mock
407+
public ColumnStatistic getColumnStatistic(Table table, String column) {
408+
return new ColumnStatistic(0, Utils.getLongFromDateTime(
409+
LocalDateTime.of(2014, 12, 01, 0, 0, 0)), 0, 0, 30);
412410
}
413411
};
414412

@@ -486,25 +484,25 @@ public void testLogicalOlapTableScanPartitionPrune1(@Mocked CachedStatisticStora
486484
}
487485

488486
@Test
489-
public void testLogicalOlapTableScanPartitionPrune2(@Mocked CachedStatisticStorage cachedStatisticStorage) {
487+
public void testLogicalOlapTableScanPartitionPrune2() {
490488
FeConstants.runningUnitTest = true;
491489
ColumnRefOperator idDate = columnRefFactory.create("id_date", Type.DATE, true);
492490

493491
GlobalStateMgr globalStateMgr = connectContext.getGlobalStateMgr();
494492
OlapTable table = (OlapTable) globalStateMgr.getLocalMetastore().getDb("statistics_test")
495493
.getTable("test_all_type_day_partition");
496494

497-
new Expectations() {
498-
{
499-
cachedStatisticStorage.getColumnStatistics(table, Lists.newArrayList("id_date"));
500-
result = new ColumnStatistic(Utils.getLongFromDateTime(LocalDateTime.of(2020, 4, 23, 0, 0, 0)),
501-
Utils.getLongFromDateTime(LocalDateTime.of(2020, 4, 25, 0, 0, 0)), 0, 0, 3);
502-
minTimes = 0;
503-
504-
cachedStatisticStorage.getColumnStatistic(table, "id_date");
505-
result = new ColumnStatistic(Utils.getLongFromDateTime(LocalDateTime.of(2020, 4, 23, 0, 0, 0)),
506-
Utils.getLongFromDateTime(LocalDateTime.of(2020, 4, 25, 0, 0, 0)), 0, 0, 3);
507-
minTimes = 0;
495+
new MockUp<CachedStatisticStorage>() {
496+
@Mock
497+
public List<ColumnStatistic> getColumnStatistics(Table table, List<String> columns) {
498+
return List.of(new ColumnStatistic(Utils.getLongFromDateTime(LocalDateTime.of(2020, 4, 23, 0, 0, 0)),
499+
Utils.getLongFromDateTime(LocalDateTime.of(2020, 4, 25, 0, 0, 0)), 0, 0, 3));
500+
}
501+
502+
@Mock
503+
public ColumnStatistic getColumnStatistic(Table table, String column) {
504+
return new ColumnStatistic(Utils.getLongFromDateTime(LocalDateTime.of(2020, 4, 23, 0, 0, 0)),
505+
Utils.getLongFromDateTime(LocalDateTime.of(2020, 4, 25, 0, 0, 0)), 0, 0, 3);
508506
}
509507
};
510508

0 commit comments

Comments
 (0)