Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,23 @@ private static ColStats<?> getPaimonColStats(
null,
null);
} else if (typeRoot.equals(DataTypeRoot.DECIMAL)) {
BigDecimal max = BigDecimal.valueOf(doubleColumnStatsData.getMax());
BigDecimal min = BigDecimal.valueOf(doubleColumnStatsData.getMin());
BigDecimal max =
doubleColumnStatsData.getMax() == null
? null
: BigDecimal.valueOf(doubleColumnStatsData.getMax());
BigDecimal min =
doubleColumnStatsData.getMin() == null
? null
: BigDecimal.valueOf(doubleColumnStatsData.getMin());
return ColStats.newColStats(
field.id(),
null != doubleColumnStatsData.getNdv()
? doubleColumnStatsData.getNdv()
: null,
null != doubleColumnStatsData.getMin()
min != null
? Decimal.fromBigDecimal(min, min.precision(), min.scale())
: null,
null != doubleColumnStatsData.getMax()
max != null
? Decimal.fromBigDecimal(max, max.precision(), max.scale())
: null,
null != doubleColumnStatsData.getNullCount()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ public void testAnalyzeTable() throws Catalog.TableNotExistException {
assertThat(newStats.get()).isSameAs(stats);
}

@Test
public void testAnalyzeAllNullDecimalColumn() throws Catalog.TableNotExistException {
sql("CREATE TABLE T (id INT, amount DECIMAL(10, 2))");
sql("INSERT INTO T VALUES (1, CAST(NULL AS DECIMAL(10, 2)))");

sql("ANALYZE TABLE T COMPUTE STATISTICS FOR ALL COLUMNS");

ColStats<?> decimalStats = paimonTable("T").statistics().get().colStats().get("amount");
assertThat(decimalStats).isEqualTo(ColStats.newColStats(1, 0L, null, null, 1L, null, null));
}

@Test
public void testAnalyzeTableColumn() throws Catalog.TableNotExistException {
sql(
Expand Down
Loading