mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(glue): read back omitted numeric string and binary column statistics as 0 (#5747)
This commit is contained in:
1 parent
23e1b3a97c
commit
b2d98d6d08
2 files changed
+91
-1
No files matched your search
@@ -609,6 +609,62 @@ class GlueServiceTest {
|
||||
assertEquals("Cannot find partition.", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void stringStatisticsWithoutAverageLengthReadBackWithZero() {
|
||||
Table table = new Table();
|
||||
table.setName("nulls");
|
||||
glueService.createTable("db1", table);
|
||||
Map<String, Object> statistics = Map.of(
|
||||
"ColumnName", "a",
|
||||
"ColumnType", "string",
|
||||
"AnalyzedTime", Instant.EPOCH,
|
||||
"StatisticsData", Map.of(
|
||||
"Type", "STRING",
|
||||
"StringColumnStatisticsData", Map.of("NumberOfNulls", 1, "NumberOfDistinctValues", 0)));
|
||||
|
||||
glueService.updateColumnStatisticsForTable("db1", "nulls", List.of(statistics));
|
||||
Map<String, Object> stored = glueService.getColumnStatisticsForTable("db1", "nulls", List.of("a"))
|
||||
.columnStatisticsList().get(0);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> data = (Map<String, Object>) ((Map<String, Object>) stored.get("StatisticsData"))
|
||||
.get("StringColumnStatisticsData");
|
||||
assertEquals(0, data.get("AverageLength"));
|
||||
assertEquals(0, data.get("MaximumLength"));
|
||||
assertEquals(1, data.get("NumberOfNulls"));
|
||||
Map<String, Object> raw = columnStatisticsStore.scan(key -> true).get(0);
|
||||
assertFalse(((Map<?, ?>) ((Map<?, ?>) raw.get("StatisticsData")).get("StringColumnStatisticsData"))
|
||||
.containsKey("AverageLength"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void partitionBinaryStatisticsWithoutLengthsReadBackWithZero() {
|
||||
Table table = new Table();
|
||||
table.setName("blobs");
|
||||
glueService.createTable("db1", table);
|
||||
Partition partition = new Partition();
|
||||
partition.setValues(List.of("1"));
|
||||
glueService.createPartition("db1", "blobs", partition);
|
||||
Map<String, Object> statistics = Map.of(
|
||||
"ColumnName", "payload",
|
||||
"ColumnType", "binary",
|
||||
"AnalyzedTime", Instant.EPOCH,
|
||||
"StatisticsData", Map.of(
|
||||
"Type", "BINARY",
|
||||
"BinaryColumnStatisticsData", Map.of("NumberOfNulls", 2)));
|
||||
|
||||
glueService.updateColumnStatisticsForPartition("db1", "blobs", List.of("1"), List.of(statistics));
|
||||
Map<String, Object> stored = glueService.getColumnStatisticsForPartition(
|
||||
"db1", "blobs", List.of("1"), List.of("payload")).columnStatisticsList().get(0);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> data = (Map<String, Object>) ((Map<String, Object>) stored.get("StatisticsData"))
|
||||
.get("BinaryColumnStatisticsData");
|
||||
assertEquals(0, data.get("MaximumLength"));
|
||||
assertEquals(0, data.get("AverageLength"));
|
||||
assertEquals(2, data.get("NumberOfNulls"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void partitionColumnStatisticsCanBeUpdatedFetchedAndDeleted() {
|
||||
Table table = new Table();
|
||||
|
||||
Reference in new issue
Block a user