|
56 | 56 | import static com.google.common.base.Verify.verify; |
57 | 57 | import static com.google.common.collect.ImmutableList.toImmutableList; |
58 | 58 | import static io.airlift.concurrent.MoreFutures.tryGetFutureValue; |
| 59 | +import static io.trino.plugin.iceberg.IcebergSessionProperties.COLLECT_EXTENDED_STATISTICS_ON_WRITE; |
59 | 60 | import static io.trino.plugin.iceberg.IcebergTestUtils.FILE_IO_FACTORY; |
60 | 61 | import static io.trino.plugin.iceberg.IcebergTestUtils.getFileSystemFactory; |
61 | 62 | import static io.trino.plugin.iceberg.IcebergTestUtils.getMetadataFileAndUpdatedMillis; |
@@ -893,6 +894,38 @@ public void testIcebergTablesSystemTable() |
893 | 894 | } |
894 | 895 | } |
895 | 896 |
|
| 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 | + |
896 | 929 | protected void dropSchema(String schema) |
897 | 930 | throws Exception |
898 | 931 | { |
|
0 commit comments