ajantha-bhat commented on code in PR #10246: URL: https://github.com/apache/iceberg/pull/10246#discussion_r1594277743
########## spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/actions/TestRewriteDataFilesAction.java: ########## @@ -180,8 +181,10 @@ public void testBinPackUnpartitionedTable() { assertThat(result.rewrittenBytesCount()).isEqualTo(dataSizeBefore); shouldHaveFiles(table, 1); - List<Object[]> actual = currentData(); + testManifestStats(table); Review Comment: We can test these at the end of the test also to avoid multiple line diff. Similarly for all the places. ########## core/src/main/java/org/apache/iceberg/FastAppend.java: ########## @@ -156,6 +156,8 @@ public List<ManifestFile> apply(TableMetadata base, Snapshot snapshot) { manifests.addAll(snapshot.allManifests(ops.io())); } + manifests.forEach(summaryBuilder::addedManifestStats); Review Comment: ping @Fokko, @amogh-jahagirdar, @dramaticlly: Can we conclude (move forward) on this based on my above comment? Having these stats will leads to better estimate based on parallelism. Agree that Having size based cost estimation will be more accurate. But count based estimation is still better than no stats. Is other engines that use CBO like Trino is intersted in these stats? cc: @findepi, @findinpath thoughts? ########## spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestSnapshotsTable.java: ########## @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.spark.sql; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.Map; +import org.apache.iceberg.MetadataTableType; +import org.apache.iceberg.spark.CatalogTestBase; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestTemplate; + +public class TestSnapshotsTable extends CatalogTestBase { + + @BeforeEach + public void createTables() { + sql( + "CREATE TABLE %s (id int, data string) USING iceberg " + + "TBLPROPERTIES" + + "('format-version'='2'," + + "'write.delete.mode'='merge-on-read')", + tableName); + sql("INSERT INTO %s VALUES (1, 'a1'),(2, 'a2'),(3, 'a3')", tableName); + } + + @AfterEach + public void removeTables() { + sql("DROP TABLE IF EXISTS %s", tableName); + } + + @TestTemplate + public void testSnapshotsTable() { + List<Object[]> sql = sql("SELECT * FROM %s.%s", tableName, MetadataTableType.SNAPSHOTS); + assertThat(sql).hasSize(1); + } + + @TestTemplate + public void testTotalDataManifestFilesWithSnapshotsTableSummary() { + List<Object[]> sql = sql("SELECT * FROM %s.%s", tableName, MetadataTableType.SNAPSHOTS); + assertThat(sql).hasSize(1); + Map<String, String> summary = (Map) sql.get(0)[5]; + assertThat(summary.get("total-data-manifest-files")).isEqualTo("1"); + assertThat(summary.get("total-delete-manifest-files")).isEqualTo(null); + sql("INSERT INTO %s VALUES (4, 'a4')", tableName); + sql = sql("SELECT * FROM %s.%s", tableName, MetadataTableType.SNAPSHOTS); + assertThat(sql).hasSize(2); + summary = (Map) sql.get(1)[5]; + assertThat(summary.get("total-data-manifest-files")).isEqualTo("2"); + assertThat(summary.get("total-delete-manifest-files")).isEqualTo(null); Review Comment: ```suggestion assertThat(summary.get("total-delete-manifest-files"))..isNull(); ``` ########## spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestSnapshotsTable.java: ########## @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.spark.sql; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.Map; +import org.apache.iceberg.MetadataTableType; +import org.apache.iceberg.spark.CatalogTestBase; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestTemplate; + +public class TestSnapshotsTable extends CatalogTestBase { + + @BeforeEach + public void createTables() { + sql( + "CREATE TABLE %s (id int, data string) USING iceberg " + + "TBLPROPERTIES" + + "('format-version'='2'," + + "'write.delete.mode'='merge-on-read')", + tableName); + sql("INSERT INTO %s VALUES (1, 'a1'),(2, 'a2'),(3, 'a3')", tableName); + } + + @AfterEach + public void removeTables() { + sql("DROP TABLE IF EXISTS %s", tableName); + } + + @TestTemplate + public void testSnapshotsTable() { + List<Object[]> sql = sql("SELECT * FROM %s.%s", tableName, MetadataTableType.SNAPSHOTS); + assertThat(sql).hasSize(1); + } + + @TestTemplate + public void testTotalDataManifestFilesWithSnapshotsTableSummary() { + List<Object[]> sql = sql("SELECT * FROM %s.%s", tableName, MetadataTableType.SNAPSHOTS); + assertThat(sql).hasSize(1); + Map<String, String> summary = (Map) sql.get(0)[5]; + assertThat(summary.get("total-data-manifest-files")).isEqualTo("1"); + assertThat(summary.get("total-delete-manifest-files")).isEqualTo(null); + sql("INSERT INTO %s VALUES (4, 'a4')", tableName); + sql = sql("SELECT * FROM %s.%s", tableName, MetadataTableType.SNAPSHOTS); + assertThat(sql).hasSize(2); + summary = (Map) sql.get(1)[5]; + assertThat(summary.get("total-data-manifest-files")).isEqualTo("2"); + assertThat(summary.get("total-delete-manifest-files")).isEqualTo(null); Review Comment: similarly check and replace all the places. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org