Skip to content

Commit 43e6b98

Browse files
WillPelechebyhr
authored andcommitted
Test ANALYZE in BaseIcebergConnectorSmokeTest
1 parent b27d16a commit 43e6b98

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorSmokeTest.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import static com.google.common.base.Verify.verify;
5757
import static com.google.common.collect.ImmutableList.toImmutableList;
5858
import static io.airlift.concurrent.MoreFutures.tryGetFutureValue;
59+
import static io.trino.plugin.iceberg.IcebergSessionProperties.COLLECT_EXTENDED_STATISTICS_ON_WRITE;
5960
import static io.trino.plugin.iceberg.IcebergTestUtils.FILE_IO_FACTORY;
6061
import static io.trino.plugin.iceberg.IcebergTestUtils.getFileSystemFactory;
6162
import static io.trino.plugin.iceberg.IcebergTestUtils.getMetadataFileAndUpdatedMillis;
@@ -893,6 +894,38 @@ public void testIcebergTablesSystemTable()
893894
}
894895
}
895896

897+
@Test
898+
public void testAnalyze()
899+
{
900+
Session noStatsOnWrite = Session.builder(getSession())
901+
.setCatalogSessionProperty("iceberg", COLLECT_EXTENDED_STATISTICS_ON_WRITE, "false")
902+
.build();
903+
904+
try (TestTable table = new TestTable(
905+
sql -> getQueryRunner().execute(noStatsOnWrite, sql),
906+
"test_analyze",
907+
"(id int)")) {
908+
assertUpdate(noStatsOnWrite, "INSERT INTO " + table.getName() + " VALUES 1, 2, 3", 3);
909+
910+
try {
911+
assertUpdate("ANALYZE " + table.getName());
912+
}
913+
catch (Exception e) {
914+
verifyAnalyzeFailurePermissible(e);
915+
return;
916+
}
917+
assertQuery("SHOW STATS FOR " + table.getName(),
918+
"VALUES " +
919+
"('id', null, 3e0, 0e0, null, '1', '3'), " +
920+
"(null, null, null, null, 3e0, null, null)");
921+
}
922+
}
923+
924+
protected String verifyAnalyzeFailurePermissible(Exception e)
925+
{
926+
throw new AssertionError("Unexpected analyze failure", e);
927+
}
928+
896929
protected void dropSchema(String schema)
897930
throws Exception
898931
{

0 commit comments

Comments
 (0)