Fokko commented on code in PR #5011: URL: https://github.com/apache/iceberg/pull/5011#discussion_r898747827
########## python/src/iceberg/table/metadata.py: ########## @@ -0,0 +1,151 @@ +# 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. + +from typing import List, Literal, Union + +from pydantic import Field + +from iceberg.schema import Schema +from iceberg.utils.iceberg_base_model import IcebergBaseModel + + +class TableMetadataCommonFields(IcebergBaseModel): + """Metadata for an Iceberg table as specified in the Apache Iceberg + spec (https://iceberg.apache.org/spec/#iceberg-table-spec)""" + + table_uuid: str = Field(alias="table-uuid") Review Comment: This is actually quite nice of Pydantic. The default json dumps doesn't allow us to encode a uuid into json: ```python ➜ python git:(fd-read-avro) python3 Python 3.9.13 (main, May 19 2022, 13:48:47) [Clang 13.1.6 (clang-1316.0.21.2)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from uuid import UUID >>> example = UUID("f79c3e09-677c-4bbd-a479-3f349cb785e7") >>> import json >>> json.dumps({"uuid": example}) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/homebrew/Cellar/[email protected]/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/opt/homebrew/Cellar/[email protected]/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/opt/homebrew/Cellar/[email protected]/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/opt/homebrew/Cellar/[email protected]/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type UUID is not JSON serializable ``` -- 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]
