This is an automated email from the ASF dual-hosted git repository.
roryqi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 5f846ed8ec [#10273] test(core): Add regression test for Lance drop
statistics with single-quoted partition names (#13665)
5f846ed8ec is described below
commit 5f846ed8ec90b0f7cc855c755a7a782746423d9d
Author: dennismdejong <[email protected]>
AuthorDate: Thu Nov 12 10:17:17 2026 +0100
[#10273] test(core): Add regression test for Lance drop statistics with
single-quoted partition names (#13665)
### What changes were proposed in this pull request?
Add the regression test proposed in #10273
(`testDropPartitionStatisticsWithSingleQuotePartitionName`). It writes
statistics for a
partition name containing a single quote (`part'ition0`) and asserts
that
`dropStatistics` no longer throws when building the Lance
`dataset.delete(...)` filter.
The underlying fix (escaping single quotes in SQL-style literals via
`escapeSqlLiteral`) was already merged in #10324 for #10165, but that PR
did not
include this exact test and did not close #10273.
### Why are the changes needed?
Fix #10273. Verify that quoted partition/statistic names do not produce
invalid
delete predicates, which is reachable from the production REST flow for
drop-partition-statistics requests when Lance partition stats storage is
enabled.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
- `./gradlew :core:test --tests
"org.apache.gravitino.stats.storage.TestLancePartitionStatisticStorage"`
(BUILD SUCCESSFUL)
- `./gradlew :core:spotlessCheck` (passes)
Co-authored-by: roryqi <[email protected]>
---
.../TestLancePartitionStatisticStorage.java | 48 ++++++++++++++++++++++
1 file changed, 48 insertions(+)
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.java
index 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();
+ }
+ }
}