jun-he commented on a change in pull request #3234: URL: https://github.com/apache/iceberg/pull/3234#discussion_r733266179
########## File path: python/src/iceberg/types.py ########## @@ -0,0 +1,117 @@ +# 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. + +class Type(object): + def __init__(self, type_string: str, repr_string: str, is_primitive=False): + self._type_string = type_string + self._repr_string = repr_string + self._is_primitive = is_primitive + + def __repr__(self): + return self._repr_string + + def __str__(self): + return self._type_string + + @property + def is_primitive(self): + return self._is_primitive + + +class FixedType(Type): + def __init__(self, length: int): + super().__init__(f"fixed[{length}]", f"FixedType[{length}]", is_primitive=True) + self._length = length + + +class DecimalType(Type): + def __init__(self, precision: int, scale: int): + super().__init__(f"decimal({precision}, {scale})", f"DecimalType({precision}, {scale})", is_primitive=True) + self._precision = precision + self._scale = scale + + def precision(self): + return self._precision + + def scale(self): + return self._scale + + +class NestedField(object): + def __init__(self, is_optional: bool, field_id: int, name: str, field_type: Type, doc=None): + self._is_optional = is_optional + self._id = field_id + self._name = name + self._type = field_type + self._doc = doc + + @property + def is_optional(self): + return self._is_optional + + @property + def is_required(self): + return not self._is_optional + + @property + def field_id(self): + return self._id + + @property + def type(self): + return self._type + + def __repr__(self): Review comment: Yep, updated. -- 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]
