CircArgs commented on a change in pull request #4016:
URL: https://github.com/apache/iceberg/pull/4016#discussion_r796560526
##########
File path: python/src/iceberg/types.py
##########
@@ -15,61 +15,84 @@
# specific language governing permissions and limitations
# under the License.
"""Data types used in describing Iceberg schemas
-
This module implements the data types described in the Iceberg specification
for Iceberg schemas. To
describe an Iceberg table schema, these classes can be used in the
construction of a StructType instance.
-
Example:
>>> StructType(
[
NestedField(True, 1, "required_field", StringType()),
NestedField(False, 2, "optional_field", IntegerType()),
]
)
-
Notes:
- https://iceberg.apache.org/#spec/#primitive-types
"""
-from typing import Optional
+from typing import Any, Dict, List, Optional, Tuple
-class Type:
- 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
+class IcebergType:
+
+ _implemented: Dict[Tuple[str, Tuple[Any]], "IcebergType"] = {}
+
+ def __new__(cls, *args, **kwargs):
Review comment:
> For the decorator example, while the object created using FixedType
will be singleton, but IIUC, the FixedType itself is a function not a class any
more, right? So we cannot call class methods from it, etc. It is better we
don't use decorator.
Decorators return a type they decorate. In this case, the decorator would
take the class and return the very same class (in contrast to most decorators
of functions which usually act as a closure and return a wrapper function) so
FixedType would still be a class, still have `__name__` FixedType and still
have all the same methods and attributes with `__new__` added via the decorator
--
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]