Skip to content

initial-default+write-default {} (struct default value) representation issue #16596

Open

Description

@Tishj

Apache Iceberg version

1.11.0 (latest release)

Query engine

None

Please describe the bug 🐞

This issue is similar to #15932

The spec has a very clear table listing behavior for struct defaults, and makes it clear that a struct column can either have null as its default value, or {}, the default values for its fields should be decomposed.

A non-null default is stored by setting initial-default or write-default to an empty struct ({}) that will use field values set from each field's initial-default or write-default, respectively.

But in the Iceberg REST API spec, both initial-default and write-default are modeled as a PrimitiveTypeValue:

        initial-default:
          $ref: "#/components/schemas/PrimitiveTypeValue"
        write-default:
          $ref: "#/components/schemas/PrimitiveTypeValue"

So I don't think we can currently represent {} for an initial-default or write-default

Example request:

{
	"stage-create": true,
	"name": "tbl",
	"schema": {
		"type": "struct",
		"fields": [
			{
				"name": "col",
				"id": 1,
				"type": {
					"type": "struct",
					"fields": [
						{
							"name": "a",
							"id": 2,
							"type": "string",
							"required": false,
							"initial-default": "test"
						},
						{
							"name": "b",
							"id": 3,
							"type": "int",
							"required": false
						}
					]
				},
				"required": false,
				"initial-default": {}
			},
			{
				"name": "col2",
				"id": 4,
				"type": "int",
				"required": false
			}
		],
		"schema-id": 0
	},
	"partition-spec": {
		"spec-id": 0,
		"type": "struct",
		"fields": []
	},
	"write-order": {
		"order-id": 0,
		"fields": []
	},
	"properties": {
		"format-version": "3"
	}
}

Attempting to POST this to the create table endpoint targeting an iceberg-rest-fixture catalog results in a long Internal Error message, of which an excerpt is:

Cannot create expression literal from org.apache.iceberg.data.GenericRecord: Record(null, null)

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Activity

  1. Tishj commented on Jul 29, 2026

    @Tishj
    Author

    Bump

  2. binarybrain-009 commented on Oct 29, 2026

    @binarybrain-009
    Contributor

    I'd like to pick this up, since #16612 was closed by the stale bot. Java can't represent a non-null struct default today: SchemaParser turns {} into a GenericRecord that Expressions.lit rejects, and NestedField only accepts null defaults for nested types. Following the review on #16612, I'd add an empty-struct default literal to Literals behind a public factory, accept it as a struct field default, read and write {} in SchemaParser, and allow it for initial-default and write-default in the REST spec. @nssalian does that direction work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions