Skip to content

Commit ca1844f

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

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

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

Lines changed: 30 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,35 @@ 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 = newTrinoTable("test_analyze", "(id int)")) {
905+
assertUpdate(noStatsOnWrite, "INSERT INTO " + table.getName() + " VALUES 1, 2, 3", 3);
906+
907+
try {
908+
assertUpdate("ANALYZE " + table.getName());
909+
}
910+
catch (Exception e) {
911+
verifyAnalyzeFailurePermissible(e);
912+
return;
913+
}
914+
assertQuery("SHOW STATS FOR " + table.getName(),
915+
"VALUES " +
916+
"('id', null, 3e0, 0e0, null, '1', '3'), " +
917+
"(null, null, null, null, 3e0, null, null)");
918+
}
919+
}
920+
921+
protected String verifyAnalyzeFailurePermissible(Exception e)
922+
{
923+
throw new AssertionError("Unexpected analyze failure", e);
924+
}
925+
896926
protected void dropSchema(String schema)
897927
throws Exception
898928
{

0 commit comments

Comments
 (0)