roryqi commented on code in PR #10149:
URL: https://github.com/apache/gravitino/pull/10149#discussion_r2878025084


##########
core/src/main/java/org/apache/gravitino/stats/storage/LancePartitionStatisticStorage.java:
##########
@@ -177,6 +180,14 @@ public LancePartitionStatisticStorage(Map<String, String> 
properties) {
         indexCacheSize > 0,
         "Lance partition statistics storage indexCacheSizeBytes must be 
positive");
 
+    this.maxStatisticsPerUpdate =
+        Integer.parseInt(
+            properties.getOrDefault(
+                MAX_STATISTICS_PER_UPDATE, 
String.valueOf(DEFAULT_MAX_STATISTICS_PER_UPDATE)));
+    Preconditions.checkArgument(

Review Comment:
   Done.



##########
core/src/test/java/org/apache/gravitino/stats/storage/TestLancePartitionStatisticStorage.java:
##########
@@ -378,6 +378,55 @@ public void testLancePartitionStatisticStorageWithCache() 
throws Exception {
     storage.close();
   }
 
+  @Test
+  public void testExceedMaxStatisticsPerUpdateLimit() throws Exception {
+    PartitionStatisticStorageFactory factory = new 
LancePartitionStatisticStorageFactory();
+
+    String metalakeName = "metalake";
+    String catalogName = "catalog";
+    String schemaName = "schema";
+    String tableName = "table";
+
+    MetadataObject metadataObject =
+        MetadataObjects.of(
+            Lists.newArrayList(catalogName, schemaName, tableName), 
MetadataObject.Type.TABLE);
+
+    EntityStore entityStore = mock(EntityStore.class);
+    TableEntity tableEntity = mock(TableEntity.class);
+    when(entityStore.get(any(), any(), any())).thenReturn(tableEntity);
+    when(tableEntity.id()).thenReturn(101L);
+    FieldUtils.writeField(GravitinoEnv.getInstance(), "entityStore", 
entityStore, true);
+
+    String location = 
Files.createTempDirectory("lance_stats_exceed_test").toString();
+    Map<String, String> properties = Maps.newHashMap();
+    properties.put("location", location);
+    // Default limit is 100, generate 101 statistics to exceed the limit
+
+    LancePartitionStatisticStorage storage =
+        (LancePartitionStatisticStorage) factory.create(properties);
+
+    // Generate 101 statistics which exceeds the default limit of 100
+    int count = 101;
+    Map<MetadataObject, Map<String, Map<String, StatisticValue<?>>>> 
originData =
+        generateData(metadataObject, count, 1);
+    Map<MetadataObject, List<PartitionStatisticsUpdate>> statisticsToUpdate =
+        convertData(originData);
+
+    List<MetadataObjectStatisticsUpdate> objectUpdates = Lists.newArrayList();
+    for (Map.Entry<MetadataObject, List<PartitionStatisticsUpdate>> entry :
+        statisticsToUpdate.entrySet()) {
+      objectUpdates.add(MetadataObjectStatisticsUpdate.of(entry.getKey(), 
entry.getValue()));
+    }
+
+    IllegalArgumentException exception =
+        Assertions.assertThrows(
+            IllegalArgumentException.class,
+            () -> storage.updateStatistics(metalakeName, objectUpdates));
+    Assertions.assertTrue(exception.getMessage().contains("exceeds the maximum 
limit"));
+
+    storage.close();

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to