Fokko opened a new pull request, #7710: URL: https://github.com/apache/iceberg/pull/7710
Noticed this when working on https://github.com/apache/iceberg/pull/6323 I believe the requirements are not defined in the right way. After generating code I got: ```python class TableRequirement(BaseModel): type: Literal[ 'assert-create', 'assert-table-uuid', 'assert-ref-snapshot-id', 'assert-last-assigned-field-id', 'assert-current-schema-id', 'assert-last-assigned-partition-id', 'assert-default-spec-id', 'assert-default-sort-order-id', ] ref: Optional[str] = None uuid: Optional[str] = None snapshot_id: Optional[int] = Field(None, alias='snapshot-id') last_assigned_field_id: Optional[int] = Field(None, alias='last-assigned-field-id') current_schema_id: Optional[int] = Field(None, alias='current-schema-id') last_assigned_partition_id: Optional[int] = Field( None, alias='last-assigned-partition-id' ) default_spec_id: Optional[int] = Field(None, alias='default-spec-id') default_sort_order_id: Optional[int] = Field(None, alias='default-sort-order-id') ``` Which encapsulates all the requirements. After the refactor in this PR, we'll end up with: ```python class AssertCreate(BaseModel): type: Literal['assert-create'] class AssertTableUUID(BaseModel): type: Literal['assert-table-uuid'] uuid: str class AssertRefSnapshotId(BaseModel): type: Literal['assert-ref-snapshot-id'] ref: str snapshot_id: int = Field(..., alias='snapshot-id') class AssertLastAssignedFieldId(BaseModel): type: Literal['assert-last-assigned-field-id'] last_assigned_partition_id: int = Field(..., alias='last-assigned-partition-id') class AssertCurrentSchemaId(BaseModel): type: Literal['assert-current-schema-id'] current_schema_id: int = Field(..., alias='current-schema-id') class AssertLastAssignedPartitionId(BaseModel): type: Literal['assert-last-assigned-partition-id'] last_assigned_partition_id: int = Field(..., alias='last-assigned-partition-id') class AssertDefaultSpecId(BaseModel): type: Literal['assert-default-spec-id'] default_spec_id: int = Field(..., alias='default-spec-id') class AssertDefaultSortOrderId(BaseModel): type: Literal['assert-default-sort-order-id'] default_sort_order_id: int = Field(..., alias='default-sort-order-id') class TableRequirement(BaseModel): __root__: Union[ AssertCreate, AssertTableUUID, AssertRefSnapshotId, AssertLastAssignedFieldId, AssertCurrentSchemaId, AssertLastAssignedPartitionId, AssertDefaultSpecId, AssertDefaultSortOrderId, ] = Field(..., discriminator='type') ``` Which makes sense to me. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
