This is an automated email from the ASF dual-hosted git repository.

laskoviymishka pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-verification.git


The following commit(s) were added to refs/heads/main by this push:
     new fb0be4d  Add reference tables for V3 default values (#28)
fb0be4d is described below

commit fb0be4d6cb2af5529a176b976b4a775dc87b778f
Author: Neelesh Salian <[email protected]>
AuthorDate: Tue Nov 17 11:03:57 2026 -0800

    Add reference tables for V3 default values (#28)
---
 reference-tables/GenerateTables.java               |  44 ++++++++++
 reference-tables/README.md                         |  26 +++---
 reference-tables/index.json                        |   8 ++
 .../v3/initial-default-parquet-data/README.md      |  91 +++++++++++++++++++++
 .../v3/initial-default-parquet-data/data/a.parquet | Bin 0 -> 683 bytes
 .../v3/initial-default-parquet-data/data/b.parquet | Bin 0 -> 1552 bytes
 .../expected/scan.json                             |  13 +++
 .../46d105ec-bb75-4543-9a28-05867759d48c-m0.avro   | Bin 0 -> 8120 bytes
 .../b2fb1500-53c2-48ca-b5c8-23971f032fbb-m0.avro   | Bin 0 -> 7837 bytes
 ...968-1-46d105ec-bb75-4543-9a28-05867759d48c.avro | Bin 0 -> 4846 bytes
 ...198-1-b2fb1500-53c2-48ca-b5c8-23971f032fbb.avro | Bin 0 -> 4765 bytes
 .../metadata/v5.metadata.json                      |   1 +
 12 files changed, 171 insertions(+), 12 deletions(-)

diff --git a/reference-tables/GenerateTables.java 
b/reference-tables/GenerateTables.java
index 2bace7e..9474b5c 100644
--- a/reference-tables/GenerateTables.java
+++ b/reference-tables/GenerateTables.java
@@ -48,11 +48,14 @@ import org.apache.iceberg.SchemaParser;
 import org.apache.iceberg.StructLike;
 import org.apache.iceberg.Table;
 import org.apache.iceberg.TableProperties;
+import org.apache.iceberg.UpdateSchema;
 import org.apache.iceberg.data.GenericRecord;
 import org.apache.iceberg.data.InternalRecordWrapper;
 import org.apache.iceberg.data.Record;
 import org.apache.iceberg.data.parquet.GenericParquetWriter;
 import org.apache.iceberg.deletes.BaseDVFileWriter;
+import org.apache.iceberg.expressions.Expressions;
+import org.apache.iceberg.expressions.Literal;
 import org.apache.iceberg.hadoop.HadoopTables;
 import org.apache.iceberg.io.CloseableIterable;
 import org.apache.iceberg.io.DataWriter;
@@ -139,6 +142,10 @@ public class GenerateTables {
         addDeletionVector(table, commit.get("deletion-vector"));
         continue;
       }
+      if (commit.has("schema-updates")) {
+        updateSchema(table, commit.get("schema-updates"));
+        continue;
+      }
       List<Record> records = new ArrayList<>();
       for (JsonNode row : commit.get("rows")) {
         records.add(record(table.schema().asStruct(), row));
@@ -200,6 +207,43 @@ public class GenerateTables {
     delta.commit();
   }
 
+  /** One schema commit of add-column and update-default actions, with 
defaults as input values. */
+  static void updateSchema(Table table, JsonNode updates) {
+    UpdateSchema update = table.updateSchema();
+    for (JsonNode u : updates) {
+      String action = u.get("action").asText();
+      String name = u.get("name").asText();
+      switch (action) {
+        case "add-column":
+          Type type = Types.fromPrimitiveString(u.get("type").asText());
+          Literal<?> initial = literal(type, u.get("initial-default"));
+          if (u.get("required").asBoolean()) {
+            update.addRequiredColumn(name, type, initial);
+          } else {
+            update.addColumn(name, type, initial);
+          }
+          break;
+        case "update-default":
+          Type current = update.apply().findType(name);
+          if (current == null) {
+            throw new IllegalArgumentException("Unknown column " + name);
+          }
+          update.updateColumnDefault(name, literal(current, 
u.get("write-default")));
+          break;
+        default:
+          throw new IllegalArgumentException("Unknown schema update action " + 
action);
+      }
+    }
+    update.commit();
+    // A schema commit leaves the table's cached metadata stale, and finish() 
reads it.
+    table.refresh();
+  }
+
+  static Literal<?> literal(Type type, JsonNode node) {
+    Object value = value(type, node);
+    return value == null ? null : Expressions.lit(value);
+  }
+
   /** A data file belongs to one partition, so every record shares the first 
record's value. */
   static DataFile write(Table table, String tag, List<Record> records) throws 
IOException {
     StructLike partition = null;
diff --git a/reference-tables/README.md b/reference-tables/README.md
index 891b19b..acfdbb1 100644
--- a/reference-tables/README.md
+++ b/reference-tables/README.md
@@ -34,12 +34,13 @@ exactly the rows in the table's `expected/scan.json`. Bytes 
are not compared.
 
 ## Size
 
-A table should stay under 100 KB. The five here are 16 KB to 31 KB.
+A table should stay under 100 KB. The six here are 16 KB to 31 KB.
 
 Size tracks commit count, and almost nothing else. A commit costs roughly 12 to
 14 KB, most of it the manifest and manifest list it produces. Rows are close to
 free: a Parquet file holding a few rows is 1 to 2 KB, about two thirds of it
-footer.
+footer. A schema change writes no manifest, only a metadata file that is then
+pruned, so it costs almost nothing.
 
 So the limit is about seven commits. A table that needs more should say why in
 its pull request.
@@ -122,15 +123,15 @@ and `org.apache.hadoop:hadoop-common` 3.4.1, and 
parquet-mr 1.17.1 comes with
 
 Each table directory holds a `README.md` whose Input section gives the table's
 format version, schema, partition spec, and each commit: the rows of one data
-file, the data files of one append, or the row positions of one data file that
-a deletion vector deletes. The generator reads that input, creates the table
-with `HadoopTables`, and commits each in turn, writing a deletion vector with
-Iceberg's `BaseDVFileWriter` in a row delta. It writes each table directly at
-the sentinel root, so the absolute paths are correct as written and nothing is
-rewritten. After writing, it prunes earlier `metadata.json` files and deletes
-Hadoop's `.crc` sidecars and `version-hint.text`. Output is not
-byte-reproducible, because Iceberg assigns random UUIDs, snapshot IDs and
-timestamps.
+file, the data files of one append, the row positions of one data file that a
+deletion vector deletes, or the updates of a schema change. The generator reads
+that input, creates the table with `HadoopTables`, and commits each in turn,
+writing a deletion vector with Iceberg's `BaseDVFileWriter` in a row delta. It
+writes each table directly at the sentinel root, so the absolute paths are
+correct as written and nothing is rewritten. After writing, it prunes earlier
+`metadata.json` files and deletes Hadoop's `.crc` sidecars and
+`version-hint.text`. Output is not byte-reproducible, because Iceberg assigns
+random UUIDs, snapshot IDs and timestamps.
 
 A table is added by writing its `README.md` and running the generator with the
 `reference-tables` directory and the table's name as arguments, for example
@@ -228,7 +229,8 @@ The rows in each file were produced by a full scan at each 
snapshot with
 PyIceberg 0.12.0, encoded as above and sorted by `id`. They were checked 
against
 a read of each snapshot's live data files with no Iceberg library: its manifest
 list, each manifest's entries not marked `DELETED`, and the rows of each data
-file those entries name, less the positions any deletion vector that applies to
+file those entries name, read by field ID with any field a file lacks filled 
from
+its `initial-default`, less the positions any deletion vector that applies to
 it deletes. The rows of `v3/deletion-vector-parquet-data` were instead derived
 from its Input, and a PyIceberg 0.12.0 scan returns the same rows.
 
diff --git a/reference-tables/index.json b/reference-tables/index.json
index e86642e..3904f09 100644
--- a/reference-tables/index.json
+++ b/reference-tables/index.json
@@ -39,6 +39,14 @@
       "data-file-format": "parquet",
       "metadata": "v3/deletion-vector-parquet-data/metadata/v3.metadata.json",
       "description": "Flat schema of long, string and int. One append of two 
data files (five and two rows), then a deletion vector that deletes positions 0 
and 3 of the first file only."
+    },
+    {
+      "name": "v3/initial-default-parquet-data",
+      "format-version": 3,
+      "written-by": "Iceberg Java 1.11.0",
+      "data-file-format": "parquet",
+      "metadata": "v3/initial-default-parquet-data/metadata/v5.metadata.json",
+      "description": "A required int added with an initial-default (42) whose 
write-default is then changed (10), an optional string added with an 
initial-default (\"none\"), and an optional string added without a default, 
after the first append. Two snapshots, four rows; rows written before the 
change read the initial-defaults and null."
     }
   ]
 }
diff --git a/reference-tables/v3/initial-default-parquet-data/README.md 
b/reference-tables/v3/initial-default-parquet-data/README.md
new file mode 100644
index 0000000..1416b08
--- /dev/null
+++ b/reference-tables/v3/initial-default-parquet-data/README.md
@@ -0,0 +1,91 @@
+<!--
+  ~ 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.
+  -->
+
+# v3/initial-default-parquet-data
+
+Input to `reference-tables/GenerateTables.java`. The schema and partition spec 
are
+the spec's JSON forms. Each commit appends one data file holding its rows, 
written
+in the spec's single-value JSON keyed by field ID, with `long` values as 
strings.
+A commit with `schema-updates` instead applies those updates as one schema 
change:
+`add-column` adds a top-level column with its `initial-default`, which also 
sets
+its `write-default`, and `update-default` changes a column's `write-default`.
+Rows of later commits are written in the evolved schema.
+
+`expected/scan.json` has no entry for the first snapshot. The spec does not say
+which schema a scan at an earlier snapshot projects, so that assertion is left
+out until it is settled.
+
+## Input
+
+```json
+{
+  "format-version": 3,
+  "description": "A required int added with an initial-default (42) whose 
write-default is then changed (10), an optional string added with an 
initial-default (\"none\"), and an optional string added without a default, 
after the first append. Two snapshots, four rows; rows written before the 
change read the initial-defaults and null.",
+  "schema": {
+    "type": "struct",
+    "schema-id": 0,
+    "fields": [
+      {
+        "id": 1,
+        "name": "id",
+        "required": true,
+        "type": "long"
+      },
+      {
+        "id": 2,
+        "name": "data",
+        "required": false,
+        "type": "string"
+      }
+    ]
+  },
+  "partition-spec": {
+    "spec-id": 0,
+    "fields": []
+  },
+  "commits": [
+    {
+      "data-file": "a",
+      "rows": [
+        {"1": "1", "2": "alpha"},
+        {"1": "2", "2": "bravo"}
+      ]
+    },
+    {
+      "schema-updates": [
+        {"action": "add-column", "name": "quantity", "type": "int", 
"required": true, "initial-default": 42},
+        {"action": "add-column", "name": "note", "type": "string", "required": 
false},
+        {"action": "add-column", "name": "label", "type": "string", 
"required": false, "initial-default": "none"}
+      ]
+    },
+    {
+      "schema-updates": [
+        {"action": "update-default", "name": "quantity", "write-default": 10}
+      ]
+    },
+    {
+      "data-file": "b",
+      "rows": [
+        {"1": "3", "2": "charlie", "3": 7, "4": "added", "5": "given"},
+        {"1": "4", "2": null, "3": 9, "4": null, "5": null}
+      ]
+    }
+  ]
+}
+```
diff --git a/reference-tables/v3/initial-default-parquet-data/data/a.parquet 
b/reference-tables/v3/initial-default-parquet-data/data/a.parquet
new file mode 100644
index 0000000..461b516
Binary files /dev/null and 
b/reference-tables/v3/initial-default-parquet-data/data/a.parquet differ
diff --git a/reference-tables/v3/initial-default-parquet-data/data/b.parquet 
b/reference-tables/v3/initial-default-parquet-data/data/b.parquet
new file mode 100644
index 0000000..0e1515e
Binary files /dev/null and 
b/reference-tables/v3/initial-default-parquet-data/data/b.parquet differ
diff --git 
a/reference-tables/v3/initial-default-parquet-data/expected/scan.json 
b/reference-tables/v3/initial-default-parquet-data/expected/scan.json
new file mode 100644
index 0000000..b11eed0
--- /dev/null
+++ b/reference-tables/v3/initial-default-parquet-data/expected/scan.json
@@ -0,0 +1,13 @@
+{
+  "snapshots": [
+    {
+      "snapshot-id": "2708989935476517968",
+      "rows": [
+        {"1": "1", "2": "alpha", "3": 42, "4": null, "5": "none"},
+        {"1": "2", "2": "bravo", "3": 42, "4": null, "5": "none"},
+        {"1": "3", "2": "charlie", "3": 7, "4": "added", "5": "given"},
+        {"1": "4", "2": null, "3": 9, "4": null, "5": null}
+      ]
+    }
+  ]
+}
diff --git 
a/reference-tables/v3/initial-default-parquet-data/metadata/46d105ec-bb75-4543-9a28-05867759d48c-m0.avro
 
b/reference-tables/v3/initial-default-parquet-data/metadata/46d105ec-bb75-4543-9a28-05867759d48c-m0.avro
new file mode 100644
index 0000000..736d5ce
Binary files /dev/null and 
b/reference-tables/v3/initial-default-parquet-data/metadata/46d105ec-bb75-4543-9a28-05867759d48c-m0.avro
 differ
diff --git 
a/reference-tables/v3/initial-default-parquet-data/metadata/b2fb1500-53c2-48ca-b5c8-23971f032fbb-m0.avro
 
b/reference-tables/v3/initial-default-parquet-data/metadata/b2fb1500-53c2-48ca-b5c8-23971f032fbb-m0.avro
new file mode 100644
index 0000000..f63714d
Binary files /dev/null and 
b/reference-tables/v3/initial-default-parquet-data/metadata/b2fb1500-53c2-48ca-b5c8-23971f032fbb-m0.avro
 differ
diff --git 
a/reference-tables/v3/initial-default-parquet-data/metadata/snap-2708989935476517968-1-46d105ec-bb75-4543-9a28-05867759d48c.avro
 
b/reference-tables/v3/initial-default-parquet-data/metadata/snap-2708989935476517968-1-46d105ec-bb75-4543-9a28-05867759d48c.avro
new file mode 100644
index 0000000..32320c7
Binary files /dev/null and 
b/reference-tables/v3/initial-default-parquet-data/metadata/snap-2708989935476517968-1-46d105ec-bb75-4543-9a28-05867759d48c.avro
 differ
diff --git 
a/reference-tables/v3/initial-default-parquet-data/metadata/snap-7626888009233711198-1-b2fb1500-53c2-48ca-b5c8-23971f032fbb.avro
 
b/reference-tables/v3/initial-default-parquet-data/metadata/snap-7626888009233711198-1-b2fb1500-53c2-48ca-b5c8-23971f032fbb.avro
new file mode 100644
index 0000000..0d181b2
Binary files /dev/null and 
b/reference-tables/v3/initial-default-parquet-data/metadata/snap-7626888009233711198-1-b2fb1500-53c2-48ca-b5c8-23971f032fbb.avro
 differ
diff --git 
a/reference-tables/v3/initial-default-parquet-data/metadata/v5.metadata.json 
b/reference-tables/v3/initial-default-parquet-data/metadata/v5.metadata.json
new file mode 100644
index 0000000..fc60756
--- /dev/null
+++ b/reference-tables/v3/initial-default-parquet-data/metadata/v5.metadata.json
@@ -0,0 +1 @@
+{"format-version":3,"table-uuid":"3f4a34f6-246e-4460-afd3-3b189af2bcba","location":"file:///tmp/iceberg-verification/reference-tables/v3/initial-default-parquet-data","last-sequence-number":2,"last-updated-ms":1794940476151,"last-column-id":5,"current-schema-id":2,"schemas":[{"type":"struct","schema-id":0,"fields":[{"id":1,"name":"id","required":true,"type":"long"},{"id":2,"name":"data","required":false,"type":"string"}]},{"type":"struct","schema-id":1,"fields":[{"id":1,"name":"id","requ
 [...]
\ No newline at end of file

Reply via email to