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 @@ -689,7 +689,9 @@ private void setColumnStatistics(String objectName, List<ColumnStatisticsObj> st
verify(!dateStatistics.isEmpty() && metastoreSupportsDateStatistics.equals(Optional.empty()));

try (ThriftMetastoreClient client = createMetastoreClient()) {
saveColumnStatistics.call(client, statisticsExceptDate);
if (!statisticsExceptDate.isEmpty()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a product test? I confirmed we can reproduce the issue in EnvSinglenode.

saveColumnStatistics.call(client, statisticsExceptDate);
}

try {
saveColumnStatistics.call(client, dateStatistics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,30 @@ public Object[][] testComputeFloatingPointStatisticsDataProvider()
};
}

@Test
public void testComputeStatisticsForTableWithOnlyDateColumns()
{
String tableName = "test_compute_statistics_with_only_date_columns";
onTrino().executeQuery("DROP TABLE IF EXISTS " + tableName);
try {
onTrino().executeQuery(format("CREATE TABLE %s AS SELECT date'2019-12-02' c_date", tableName));

List<Row> expectedStatistics = ImmutableList.of(
isHiveVersionBefore12()
? row("c_date", null, null, null, null, null, null)
: row("c_date", null, 1.0, 0.0, null, "2019-12-02", "2019-12-02"),
row(null, null, null, null, 1.0, null, null));

assertThat(onTrino().executeQuery("SHOW STATS FOR " + tableName)).containsOnly(expectedStatistics);

onTrino().executeQuery("ANALYZE " + tableName);
assertThat(onTrino().executeQuery("SHOW STATS FOR " + tableName)).containsOnly(expectedStatistics);
}
finally {
onTrino().executeQuery("DROP TABLE IF EXISTS " + tableName);
}
}

@Test
@Flaky(issue = ERROR_COMMITTING_WRITE_TO_HIVE_ISSUE, match = ERROR_COMMITTING_WRITE_TO_HIVE_MATCH)
public void testMixedHiveAndPrestoStatistics()
Expand Down