|
53 | 53 | import com.starrocks.sql.plan.ConnectorPlanTestBase; |
54 | 54 | import com.starrocks.utframe.StarRocksAssert; |
55 | 55 | import com.starrocks.utframe.UtFrameUtils; |
56 | | -import mockit.Expectations; |
57 | 56 | import mockit.Mock; |
58 | 57 | import mockit.MockUp; |
59 | | -import mockit.Mocked; |
60 | 58 | import org.junit.jupiter.api.AfterEach; |
61 | 59 | import org.junit.jupiter.api.Assertions; |
62 | 60 | import org.junit.jupiter.api.BeforeAll; |
@@ -391,24 +389,24 @@ public List<ColumnStatistic> getColumnStatistics(Table table, List<String> colum |
391 | 389 | } |
392 | 390 |
|
393 | 391 | @Test |
394 | | - public void testLogicalOlapTableScanPartitionPrune1(@Mocked CachedStatisticStorage cachedStatisticStorage) { |
| 392 | + public void testLogicalOlapTableScanPartitionPrune1() { |
395 | 393 | FeConstants.runningUnitTest = true; |
396 | 394 | ColumnRefOperator idDate = columnRefFactory.create("id_date", Type.DATE, true); |
397 | 395 |
|
398 | 396 | GlobalStateMgr globalStateMgr = connectContext.getGlobalStateMgr(); |
399 | 397 | Table table = globalStateMgr.getLocalMetastore().getDb("statistics_test").getTable("test_all_type"); |
400 | 398 |
|
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); |
412 | 410 | } |
413 | 411 | }; |
414 | 412 |
|
@@ -486,25 +484,25 @@ public void testLogicalOlapTableScanPartitionPrune1(@Mocked CachedStatisticStora |
486 | 484 | } |
487 | 485 |
|
488 | 486 | @Test |
489 | | - public void testLogicalOlapTableScanPartitionPrune2(@Mocked CachedStatisticStorage cachedStatisticStorage) { |
| 487 | + public void testLogicalOlapTableScanPartitionPrune2() { |
490 | 488 | FeConstants.runningUnitTest = true; |
491 | 489 | ColumnRefOperator idDate = columnRefFactory.create("id_date", Type.DATE, true); |
492 | 490 |
|
493 | 491 | GlobalStateMgr globalStateMgr = connectContext.getGlobalStateMgr(); |
494 | 492 | OlapTable table = (OlapTable) globalStateMgr.getLocalMetastore().getDb("statistics_test") |
495 | 493 | .getTable("test_all_type_day_partition"); |
496 | 494 |
|
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); |
508 | 506 | } |
509 | 507 | }; |
510 | 508 |
|
|
0 commit comments