Skip to content

Commit 9e57706

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

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

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

Lines changed: 29 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,34 @@ 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+
assertThat(query("SHOW STATS FOR " + table.getName())).result()
915+
.projected("column_name", "distinct_values_count")
916+
.matches("VALUES (VARCHAR 'id', 3e0), (null, null)");
917+
}
918+
}
919+
920+
protected void verifyAnalyzeFailurePermissible(Exception e)
921+
{
922+
throw new AssertionError("Unexpected analyze failure", e);
923+
}
924+
896925
protected void dropSchema(String schema)
897926
throws Exception
898927
{

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest/TestIcebergS3TablesConnectorSmokeTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ protected void dropTableFromMetastore(String tableName)
123123
throw new UnsupportedOperationException();
124124
}
125125

126+
@Override
127+
protected void verifyAnalyzeFailurePermissible(Exception e)
128+
{
129+
assertThat(e).hasMessageContaining("S3 Tables do not support analyze");
130+
}
131+
126132
@Test
127133
@Override // Override because the location pattern differs
128134
public void testShowCreateTable()

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/rest/TestIcebergUnityRestCatalogConnectorSmokeTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,4 +548,12 @@ public void testMetadataDeleteAfterCommitEnabled()
548548
assertThatThrownBy(super::testMetadataDeleteAfterCommitEnabled)
549549
.hasStackTraceContaining("Access Denied");
550550
}
551+
552+
@Test
553+
@Override
554+
public void testAnalyze()
555+
{
556+
assertThatThrownBy(super::testAnalyze)
557+
.hasStackTraceContaining("Access Denied");
558+
}
551559
}

plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/snowflake/TestIcebergSnowflakeCatalogConnectorSmokeTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,14 @@ public void testCreateOrReplaceWithTableChangesFunction()
522522
.hasMessageMatching("Snowflake managed Iceberg tables do not support modifications");
523523
}
524524

525+
@Test
526+
@Override
527+
public void testAnalyze()
528+
{
529+
assertThatThrownBy(super::testAnalyze)
530+
.hasMessageMatching("Snowflake managed Iceberg tables do not support modifications");
531+
}
532+
525533
@Test
526534
public void testNation()
527535
{

0 commit comments

Comments
 (0)