fix: Handle optional properties in load namespace properties response by geruh · Pull Request #3169 · apache/iceberg-python

Closes #3167

Rationale for this change

The rest spec model GetNamespaceResponse defines the properties field as optional, and nullable. Also, following the description if the rest catalog doesn't support ns properties they should return null.

Link: https://github.com/apache/iceberg/blob/0a73da119ff38ee3a98f248b42180caa51001cec/open-api/rest-catalog-open-api.yaml#L4146-L4163

    GetNamespaceResponse:
      type: object
      required:
        - namespace
      properties:
        namespace:
          $ref: '#/components/schemas/Namespace'
        properties:
          type: object
          description:
            Properties stored on the namespace, if supported by the server.
            If the server does not support namespace properties, it should return null for this field.
            If namespace properties are supported, but none are set, it should return an empty object.
          additionalProperties:
            type: string
          example: { "owner": "Ralph", 'transient_lastDdlTime': '1452120468' }
          default: { }
          nullable: true

Looks like the pydantic models raise a ValidationError in the optional/null cases as seen in the issue above. So this PR adds a fix to handle these cases.

Are these changes tested?

Yes, added tests and tested with s3tables api

Are there any user-facing changes?

Not really