World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#10273] test(core): Add regression test for Lance drop statistics with single-quoted partition names (#13665)
dennismdejong5f846ed8ec90
diff --git a/core/src/test/java/org/apache/gravitino/stats/storage/TestLancePartitionStatisticStorage.java b/core/src/test/java/org/apache/gravitino/stats/storage/TestLancePartitionStatisticStorage.javaindex 0203c77799..562fbe6f3a 100644--- a/core/src/test/java/org/apache/gravitino/stats/storage/TestLancePartitionStatisticStorage.java+++ b/core/src/test/java/org/apache/gravitino/stats/storage/TestLancePartitionStatisticStorage.java@@ -424,4 +424,52 @@ public class TestLancePartitionStatisticStorage {storage.close();}}++ @Test+ public void testDropPartitionStatisticsWithSingleQuotePartitionName() throws Exception {+ PartitionStatisticStorageFactory factory = new LancePartitionStatisticStorageFactory();++ String metalakeName = "metalake";+ MetadataObject metadataObject =+ MetadataObjects.of(+ Lists.newArrayList("catalog", "schema", "table"), 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(202L);+ FieldUtils.writeField(GravitinoEnv.getInstance(), "entityStore", entityStore, true);++ String location = Files.createTempDirectory("lance_stats_quote_drop_test").toString();+ Map<String, String> properties = Maps.newHashMap();+ properties.put("location", location);+ LancePartitionStatisticStorage storage =+ (LancePartitionStatisticStorage) factory.create(properties);++ try {+ Map<String, StatisticValue<?>> statistics = Maps.newHashMap();+ statistics.put("statistic0", StatisticValues.longValue(1L));++ List<MetadataObjectStatisticsUpdate> updates =+ Lists.newArrayList(+ MetadataObjectStatisticsUpdate.of(+ metadataObject,+ Lists.newArrayList(+ PartitionStatisticsModification.update("part'ition0", statistics))));+ storage.updateStatistics(metalakeName, updates);++ List<MetadataObjectStatisticsDrop> drops =+ Lists.newArrayList(+ MetadataObjectStatisticsDrop.of(+ metadataObject,+ Lists.newArrayList(+ PartitionStatisticsModification.drop(+ "part'ition0", Lists.newArrayList("statistic0")))));++ Assertions.assertDoesNotThrow(() -> storage.dropStatistics(metalakeName, drops));+ } finally {+ FileUtils.deleteDirectory(new File(location + "/" + tableEntity.id() + ".lance"));+ storage.close();+ }+ }}