From fa43d960d2c81de42c4deeb81e1ebd68725e5521 Mon Sep 17 00:00:00 2001 From: Evan Wu Date: Sun, 28 Jun 2026 00:18:47 -0700 Subject: [PATCH 1/2] Build: Bump datamodel-code-generator from 0.63.0 to 0.64.1 Regenerate open-api/rest-catalog-open-api.py with datamodel-code-generator 0.64.1. As of 0.64.0, optional primitive const fields no longer emit the const value as an injected default, so the generated discriminator fields (action/type) are now `Literal[...] | None = None`. Committing the regenerated output keeps `make generate` + `git diff --exit-code` green. Supersedes #16985. Co-Authored-By: Claude Opus 4.8 --- open-api/requirements.txt | 2 +- open-api/rest-catalog-open-api.py | 64 +++++++++++++++---------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/open-api/requirements.txt b/open-api/requirements.txt index 35dc0d4b4d57..3e3b59c33bb4 100644 --- a/open-api/requirements.txt +++ b/open-api/requirements.txt @@ -16,5 +16,5 @@ # under the License. openapi-spec-validator==0.9.0 -datamodel-code-generator==0.63.0 +datamodel-code-generator==0.64.1 yamllint==1.38.0 diff --git a/open-api/rest-catalog-open-api.py b/open-api/rest-catalog-open-api.py index 7b6c4f73fc9e..45952b01ccce 100644 --- a/open-api/rest-catalog-open-api.py +++ b/open-api/rest-catalog-open-api.py @@ -368,17 +368,17 @@ class AssignUUIDUpdate(BaseUpdate): Assigning a UUID to a table/view should only be done when creating the table/view. It is not safe to re-assign the UUID if a table/view already has a UUID assigned """ - action: Literal['assign-uuid'] = 'assign-uuid' + action: Literal['assign-uuid'] | None = None uuid: str class UpgradeFormatVersionUpdate(BaseUpdate): - action: Literal['upgrade-format-version'] = 'upgrade-format-version' + action: Literal['upgrade-format-version'] | None = None format_version: int = Field(..., alias='format-version') class SetCurrentSchemaUpdate(BaseUpdate): - action: Literal['set-current-schema'] = 'set-current-schema' + action: Literal['set-current-schema'] | None = None schema_id: int = Field( ..., alias='schema-id', @@ -387,12 +387,12 @@ class SetCurrentSchemaUpdate(BaseUpdate): class AddPartitionSpecUpdate(BaseUpdate): - action: Literal['add-spec'] = 'add-spec' + action: Literal['add-spec'] | None = None spec: PartitionSpec class SetDefaultSpecUpdate(BaseUpdate): - action: Literal['set-default-spec'] = 'set-default-spec' + action: Literal['set-default-spec'] | None = None spec_id: int = Field( ..., alias='spec-id', @@ -401,12 +401,12 @@ class SetDefaultSpecUpdate(BaseUpdate): class AddSortOrderUpdate(BaseUpdate): - action: Literal['add-sort-order'] = 'add-sort-order' + action: Literal['add-sort-order'] | None = None sort_order: SortOrder = Field(..., alias='sort-order') class SetDefaultSortOrderUpdate(BaseUpdate): - action: Literal['set-default-sort-order'] = 'set-default-sort-order' + action: Literal['set-default-sort-order'] | None = None sort_order_id: int = Field( ..., alias='sort-order-id', @@ -415,47 +415,47 @@ class SetDefaultSortOrderUpdate(BaseUpdate): class AddSnapshotUpdate(BaseUpdate): - action: Literal['add-snapshot'] = 'add-snapshot' + action: Literal['add-snapshot'] | None = None snapshot: Snapshot class SetSnapshotRefUpdate(BaseUpdate, SnapshotReference): - action: Literal['set-snapshot-ref'] = 'set-snapshot-ref' + action: Literal['set-snapshot-ref'] | None = None ref_name: str = Field(..., alias='ref-name') class RemoveSnapshotsUpdate(BaseUpdate): - action: Literal['remove-snapshots'] = 'remove-snapshots' + action: Literal['remove-snapshots'] | None = None snapshot_ids: list[int] = Field(..., alias='snapshot-ids') class RemoveSnapshotRefUpdate(BaseUpdate): - action: Literal['remove-snapshot-ref'] = 'remove-snapshot-ref' + action: Literal['remove-snapshot-ref'] | None = None ref_name: str = Field(..., alias='ref-name') class SetLocationUpdate(BaseUpdate): - action: Literal['set-location'] = 'set-location' + action: Literal['set-location'] | None = None location: str class SetPropertiesUpdate(BaseUpdate): - action: Literal['set-properties'] = 'set-properties' + action: Literal['set-properties'] | None = None updates: dict[str, str] class RemovePropertiesUpdate(BaseUpdate): - action: Literal['remove-properties'] = 'remove-properties' + action: Literal['remove-properties'] | None = None removals: list[str] class AddViewVersionUpdate(BaseUpdate): - action: Literal['add-view-version'] = 'add-view-version' + action: Literal['add-view-version'] | None = None view_version: ViewVersion = Field(..., alias='view-version') class SetCurrentViewVersionUpdate(BaseUpdate): - action: Literal['set-current-view-version'] = 'set-current-view-version' + action: Literal['set-current-view-version'] | None = None view_version_id: int = Field( ..., alias='view-version-id', @@ -464,32 +464,32 @@ class SetCurrentViewVersionUpdate(BaseUpdate): class RemoveStatisticsUpdate(BaseUpdate): - action: Literal['remove-statistics'] = 'remove-statistics' + action: Literal['remove-statistics'] | None = None snapshot_id: int = Field(..., alias='snapshot-id') class RemovePartitionStatisticsUpdate(BaseUpdate): - action: Literal['remove-partition-statistics'] = 'remove-partition-statistics' + action: Literal['remove-partition-statistics'] | None = None snapshot_id: int = Field(..., alias='snapshot-id') class RemovePartitionSpecsUpdate(BaseUpdate): - action: Literal['remove-partition-specs'] = 'remove-partition-specs' + action: Literal['remove-partition-specs'] | None = None spec_ids: list[int] = Field(..., alias='spec-ids') class RemoveSchemasUpdate(BaseUpdate): - action: Literal['remove-schemas'] = 'remove-schemas' + action: Literal['remove-schemas'] | None = None schema_ids: list[int] = Field(..., alias='schema-ids') class AddEncryptionKeyUpdate(BaseUpdate): - action: Literal['add-encryption-key'] = 'add-encryption-key' + action: Literal['add-encryption-key'] | None = None encryption_key: EncryptedKey = Field(..., alias='encryption-key') class RemoveEncryptionKeyUpdate(BaseUpdate): - action: Literal['remove-encryption-key'] = 'remove-encryption-key' + action: Literal['remove-encryption-key'] | None = None key_id: str = Field(..., alias='key-id') @@ -522,7 +522,7 @@ class AssertRefSnapshotId(TableRequirement): """ - type: Literal['assert-ref-snapshot-id'] = 'assert-ref-snapshot-id' + type: Literal['assert-ref-snapshot-id'] | None = None ref: str snapshot_id: int = Field(..., alias='snapshot-id') @@ -532,7 +532,7 @@ class AssertLastAssignedFieldId(TableRequirement): The table's last assigned column id must match the requirement's `last-assigned-field-id` """ - type: Literal['assert-last-assigned-field-id'] = 'assert-last-assigned-field-id' + type: Literal['assert-last-assigned-field-id'] | None = None last_assigned_field_id: int = Field(..., alias='last-assigned-field-id') @@ -541,7 +541,7 @@ class AssertCurrentSchemaId(TableRequirement): The table's current schema id must match the requirement's `current-schema-id` """ - type: Literal['assert-current-schema-id'] = 'assert-current-schema-id' + type: Literal['assert-current-schema-id'] | None = None current_schema_id: int = Field(..., alias='current-schema-id') @@ -550,9 +550,7 @@ class AssertLastAssignedPartitionId(TableRequirement): The table's last assigned partition id must match the requirement's `last-assigned-partition-id` """ - type: Literal['assert-last-assigned-partition-id'] = ( - 'assert-last-assigned-partition-id' - ) + type: Literal['assert-last-assigned-partition-id'] | None = None last_assigned_partition_id: int = Field(..., alias='last-assigned-partition-id') @@ -561,7 +559,7 @@ class AssertDefaultSpecId(TableRequirement): The table's default spec id must match the requirement's `default-spec-id` """ - type: Literal['assert-default-spec-id'] = 'assert-default-spec-id' + type: Literal['assert-default-spec-id'] | None = None default_spec_id: int = Field(..., alias='default-spec-id') @@ -570,7 +568,7 @@ class AssertDefaultSortOrderId(TableRequirement): The table's default sort order id must match the requirement's `default-sort-order-id` """ - type: Literal['assert-default-sort-order-id'] = 'assert-default-sort-order-id' + type: Literal['assert-default-sort-order-id'] | None = None default_sort_order_id: int = Field(..., alias='default-sort-order-id') @@ -1144,7 +1142,7 @@ class TransformTerm(BaseModel): class SetPartitionStatisticsUpdate(BaseUpdate): - action: Literal['set-partition-statistics'] = 'set-partition-statistics' + action: Literal['set-partition-statistics'] | None = None partition_statistics: PartitionStatisticsFile = Field( ..., alias='partition-statistics' ) @@ -1254,7 +1252,7 @@ class Term(RootModel[Reference | TransformTerm]): class SetStatisticsUpdate(BaseUpdate): - action: Literal['set-statistics'] = 'set-statistics' + action: Literal['set-statistics'] | None = None snapshot_id: int | None = Field( None, alias='snapshot-id', @@ -1518,7 +1516,7 @@ class ViewMetadata(BaseModel): class AddSchemaUpdate(BaseUpdate): - action: Literal['add-schema'] = 'add-schema' + action: Literal['add-schema'] | None = None schema_: Schema = Field(..., alias='schema') last_column_id: int | None = Field( None, From 52bf19a2978bf1e1c9bae2bcff3649d64d27f6e3 Mon Sep 17 00:00:00 2001 From: Evan Wu Date: Sun, 28 Jun 2026 11:29:36 -0700 Subject: [PATCH 2/2] Mark REST spec discriminators as required so they are not generated as nullable --- open-api/rest-catalog-open-api.py | 62 ++++++++++++++--------------- open-api/rest-catalog-open-api.yaml | 31 +++++++++++++++ 2 files changed, 62 insertions(+), 31 deletions(-) diff --git a/open-api/rest-catalog-open-api.py b/open-api/rest-catalog-open-api.py index 45952b01ccce..99fe855147c8 100644 --- a/open-api/rest-catalog-open-api.py +++ b/open-api/rest-catalog-open-api.py @@ -368,17 +368,17 @@ class AssignUUIDUpdate(BaseUpdate): Assigning a UUID to a table/view should only be done when creating the table/view. It is not safe to re-assign the UUID if a table/view already has a UUID assigned """ - action: Literal['assign-uuid'] | None = None + action: Literal['assign-uuid'] uuid: str class UpgradeFormatVersionUpdate(BaseUpdate): - action: Literal['upgrade-format-version'] | None = None + action: Literal['upgrade-format-version'] format_version: int = Field(..., alias='format-version') class SetCurrentSchemaUpdate(BaseUpdate): - action: Literal['set-current-schema'] | None = None + action: Literal['set-current-schema'] schema_id: int = Field( ..., alias='schema-id', @@ -387,12 +387,12 @@ class SetCurrentSchemaUpdate(BaseUpdate): class AddPartitionSpecUpdate(BaseUpdate): - action: Literal['add-spec'] | None = None + action: Literal['add-spec'] spec: PartitionSpec class SetDefaultSpecUpdate(BaseUpdate): - action: Literal['set-default-spec'] | None = None + action: Literal['set-default-spec'] spec_id: int = Field( ..., alias='spec-id', @@ -401,12 +401,12 @@ class SetDefaultSpecUpdate(BaseUpdate): class AddSortOrderUpdate(BaseUpdate): - action: Literal['add-sort-order'] | None = None + action: Literal['add-sort-order'] sort_order: SortOrder = Field(..., alias='sort-order') class SetDefaultSortOrderUpdate(BaseUpdate): - action: Literal['set-default-sort-order'] | None = None + action: Literal['set-default-sort-order'] sort_order_id: int = Field( ..., alias='sort-order-id', @@ -415,47 +415,47 @@ class SetDefaultSortOrderUpdate(BaseUpdate): class AddSnapshotUpdate(BaseUpdate): - action: Literal['add-snapshot'] | None = None + action: Literal['add-snapshot'] snapshot: Snapshot class SetSnapshotRefUpdate(BaseUpdate, SnapshotReference): - action: Literal['set-snapshot-ref'] | None = None + action: Literal['set-snapshot-ref'] ref_name: str = Field(..., alias='ref-name') class RemoveSnapshotsUpdate(BaseUpdate): - action: Literal['remove-snapshots'] | None = None + action: Literal['remove-snapshots'] snapshot_ids: list[int] = Field(..., alias='snapshot-ids') class RemoveSnapshotRefUpdate(BaseUpdate): - action: Literal['remove-snapshot-ref'] | None = None + action: Literal['remove-snapshot-ref'] ref_name: str = Field(..., alias='ref-name') class SetLocationUpdate(BaseUpdate): - action: Literal['set-location'] | None = None + action: Literal['set-location'] location: str class SetPropertiesUpdate(BaseUpdate): - action: Literal['set-properties'] | None = None + action: Literal['set-properties'] updates: dict[str, str] class RemovePropertiesUpdate(BaseUpdate): - action: Literal['remove-properties'] | None = None + action: Literal['remove-properties'] removals: list[str] class AddViewVersionUpdate(BaseUpdate): - action: Literal['add-view-version'] | None = None + action: Literal['add-view-version'] view_version: ViewVersion = Field(..., alias='view-version') class SetCurrentViewVersionUpdate(BaseUpdate): - action: Literal['set-current-view-version'] | None = None + action: Literal['set-current-view-version'] view_version_id: int = Field( ..., alias='view-version-id', @@ -464,32 +464,32 @@ class SetCurrentViewVersionUpdate(BaseUpdate): class RemoveStatisticsUpdate(BaseUpdate): - action: Literal['remove-statistics'] | None = None + action: Literal['remove-statistics'] snapshot_id: int = Field(..., alias='snapshot-id') class RemovePartitionStatisticsUpdate(BaseUpdate): - action: Literal['remove-partition-statistics'] | None = None + action: Literal['remove-partition-statistics'] snapshot_id: int = Field(..., alias='snapshot-id') class RemovePartitionSpecsUpdate(BaseUpdate): - action: Literal['remove-partition-specs'] | None = None + action: Literal['remove-partition-specs'] spec_ids: list[int] = Field(..., alias='spec-ids') class RemoveSchemasUpdate(BaseUpdate): - action: Literal['remove-schemas'] | None = None + action: Literal['remove-schemas'] schema_ids: list[int] = Field(..., alias='schema-ids') class AddEncryptionKeyUpdate(BaseUpdate): - action: Literal['add-encryption-key'] | None = None + action: Literal['add-encryption-key'] encryption_key: EncryptedKey = Field(..., alias='encryption-key') class RemoveEncryptionKeyUpdate(BaseUpdate): - action: Literal['remove-encryption-key'] | None = None + action: Literal['remove-encryption-key'] key_id: str = Field(..., alias='key-id') @@ -522,7 +522,7 @@ class AssertRefSnapshotId(TableRequirement): """ - type: Literal['assert-ref-snapshot-id'] | None = None + type: Literal['assert-ref-snapshot-id'] ref: str snapshot_id: int = Field(..., alias='snapshot-id') @@ -532,7 +532,7 @@ class AssertLastAssignedFieldId(TableRequirement): The table's last assigned column id must match the requirement's `last-assigned-field-id` """ - type: Literal['assert-last-assigned-field-id'] | None = None + type: Literal['assert-last-assigned-field-id'] last_assigned_field_id: int = Field(..., alias='last-assigned-field-id') @@ -541,7 +541,7 @@ class AssertCurrentSchemaId(TableRequirement): The table's current schema id must match the requirement's `current-schema-id` """ - type: Literal['assert-current-schema-id'] | None = None + type: Literal['assert-current-schema-id'] current_schema_id: int = Field(..., alias='current-schema-id') @@ -550,7 +550,7 @@ class AssertLastAssignedPartitionId(TableRequirement): The table's last assigned partition id must match the requirement's `last-assigned-partition-id` """ - type: Literal['assert-last-assigned-partition-id'] | None = None + type: Literal['assert-last-assigned-partition-id'] last_assigned_partition_id: int = Field(..., alias='last-assigned-partition-id') @@ -559,7 +559,7 @@ class AssertDefaultSpecId(TableRequirement): The table's default spec id must match the requirement's `default-spec-id` """ - type: Literal['assert-default-spec-id'] | None = None + type: Literal['assert-default-spec-id'] default_spec_id: int = Field(..., alias='default-spec-id') @@ -568,7 +568,7 @@ class AssertDefaultSortOrderId(TableRequirement): The table's default sort order id must match the requirement's `default-sort-order-id` """ - type: Literal['assert-default-sort-order-id'] | None = None + type: Literal['assert-default-sort-order-id'] default_sort_order_id: int = Field(..., alias='default-sort-order-id') @@ -1142,7 +1142,7 @@ class TransformTerm(BaseModel): class SetPartitionStatisticsUpdate(BaseUpdate): - action: Literal['set-partition-statistics'] | None = None + action: Literal['set-partition-statistics'] partition_statistics: PartitionStatisticsFile = Field( ..., alias='partition-statistics' ) @@ -1252,7 +1252,7 @@ class Term(RootModel[Reference | TransformTerm]): class SetStatisticsUpdate(BaseUpdate): - action: Literal['set-statistics'] | None = None + action: Literal['set-statistics'] snapshot_id: int | None = Field( None, alias='snapshot-id', @@ -1516,7 +1516,7 @@ class ViewMetadata(BaseModel): class AddSchemaUpdate(BaseUpdate): - action: Literal['add-schema'] | None = None + action: Literal['add-schema'] schema_: Schema = Field(..., alias='schema') last_column_id: int | None = Field( None, diff --git a/open-api/rest-catalog-open-api.yaml b/open-api/rest-catalog-open-api.yaml index 990f2285e53b..b5fe7f69e37d 100644 --- a/open-api/rest-catalog-open-api.yaml +++ b/open-api/rest-catalog-open-api.yaml @@ -3093,6 +3093,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - uuid properties: action: @@ -3105,6 +3106,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - format-version properties: action: @@ -3117,6 +3119,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - schema properties: action: @@ -3138,6 +3141,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - schema-id properties: action: @@ -3151,6 +3155,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - spec properties: action: @@ -3163,6 +3168,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - spec-id properties: action: @@ -3176,6 +3182,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - sort-order properties: action: @@ -3188,6 +3195,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - sort-order-id properties: action: @@ -3201,6 +3209,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - snapshot properties: action: @@ -3214,6 +3223,7 @@ components: - $ref: '#/components/schemas/BaseUpdate' - $ref: '#/components/schemas/SnapshotReference' required: + - action - ref-name properties: action: @@ -3226,6 +3236,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - snapshot-ids properties: action: @@ -3241,6 +3252,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - ref-name properties: action: @@ -3253,6 +3265,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - location properties: action: @@ -3265,6 +3278,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - updates properties: action: @@ -3279,6 +3293,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - removals properties: action: @@ -3293,6 +3308,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - view-version properties: action: @@ -3305,6 +3321,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - view-version-id properties: action: @@ -3318,6 +3335,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - statistics properties: action: @@ -3337,6 +3355,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - snapshot-id properties: action: @@ -3350,6 +3369,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - partition-statistics properties: action: @@ -3362,6 +3382,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - snapshot-id properties: action: @@ -3375,6 +3396,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - spec-ids properties: action: @@ -3389,6 +3411,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - schema-ids properties: action: @@ -3403,6 +3426,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - encryption-key properties: action: @@ -3415,6 +3439,7 @@ components: allOf: - $ref: '#/components/schemas/BaseUpdate' required: + - action - key-id properties: action: @@ -3513,6 +3538,7 @@ components: allOf: - $ref: '#/components/schemas/TableRequirement' required: + - type - ref - snapshot-id properties: @@ -3532,6 +3558,7 @@ components: allOf: - $ref: '#/components/schemas/TableRequirement' required: + - type - last-assigned-field-id properties: type: @@ -3546,6 +3573,7 @@ components: allOf: - $ref: '#/components/schemas/TableRequirement' required: + - type - current-schema-id properties: type: @@ -3560,6 +3588,7 @@ components: allOf: - $ref: '#/components/schemas/TableRequirement' required: + - type - last-assigned-partition-id properties: type: @@ -3574,6 +3603,7 @@ components: allOf: - $ref: '#/components/schemas/TableRequirement' required: + - type - default-spec-id properties: type: @@ -3588,6 +3618,7 @@ components: allOf: - $ref: '#/components/schemas/TableRequirement' required: + - type - default-sort-order-id properties: type: