You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/01/03 22:11:44 UTC

[GitHub] [iceberg] CircArgs opened a new pull request #3839: Expanding primitive types to individual classes

CircArgs opened a new pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839


   This PR is to solve having to do `isinstance` or `==` when checking types. 
   
   ```python
   from iceberg.types import BooleanType, Boolean
   x = BooleanType
   isinstance(x, Boolean)  # True
   ```
   No changes to tests. This also should not conflict with other PRs.
   
   


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783452232



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """An Integer data type in Iceberg can be represented using an instance of this class. Integers in Iceberg are
       32-bit signed and can be promoted to Longs.
   
       Example:
           >>> column_foo = IntegerType()
           >>> isinstance(column_foo, IntegerType)
           True
   
       Attributes:
           max (int): The maximum allowed value for Integers, inherited from the canonical Iceberg implementation
             in Java (returns `2147483647`)
           min (int): The minimum allowed value for Integers, inherited from the canonical Iceberg implementation
             in Java (returns `-2147483648`)
       """
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783355425



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):

Review comment:
       Looks like you're using `Boolean` instead of `BooleanType` because you still create instances below all of the classes. I don't think that we need to maintain backward compatibility yet, so I would probably recommend renaming these to `BooleanType`, `IntegerType`, etc.




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783354516



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       @samredai, can you suggest updates to these docstrings that conform to the style and content that we want to use? I like the ones in #3450 and I would expect these to provide a bit more information other than a link.




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#issuecomment-1015941836


   Looks great! I'll merge when tests are passing.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783467609



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A Time data type in Iceberg can be represented using an instance of this class. Times in Iceberg
       have microsecond precision and are a time of day without a date or timezone.
   
       Example:
           >>> column_foo = TimeType()
           >>> isinstance(column_foo, TimeType)
           True
       """
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783470432



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A Timestamp data type in Iceberg can be represented using an instance of this class. Timestamps in
       Iceberg have microsecond precision and include a date and a time of day without a timezone.
   
       Example:
           >>> column_foo = TimestampType()
           >>> isinstance(column_foo, TimestampType)
           True
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A Timestamptz data type in Iceberg can be represented using an instance of this class. Timestamptzs in
       Iceberg are stored as UTC and include a date and a time of day with a timezone.
   
       Example:
           >>> column_foo = TimestamptzType()
           >>> isinstance(column_foo, TimestamptzType)
           True
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A String data type in Iceberg can be represented using an instance of this class. Strings in
       Iceberg are arbitrary-length character sequences and are encoded with UTF-8.
   
       Example:
           >>> column_foo = StringType()
           >>> isinstance(column_foo, StringType)
           True
       """
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r781570743



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       Can you update these links to use `/spec/#primitive-types` rather than with the extra `#` before `spec`? Those links would break soon.




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783446761



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A boolean data type in Iceberg can be represented using an instance of this class.
   
       Example:
           >>> column_foo = BooleanType()
           >>> isinstance(column_foo, BooleanType)
           True
       """
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783463645



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A Date data type in Iceberg can be represented using an instance of this class. Dates in Iceberg are
       calendar dates without a timezone or time.
   
       Example:
           >>> column_foo = DateType()
           >>> isinstance(column_foo, DateType)
           True
       """
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783534464



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       I'm not sure that we need the first line that isn't specific to the type class. The second line seems like a good one though: "A boolean data type in an Iceberg schema"?




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] CircArgs commented on pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
CircArgs commented on pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#issuecomment-1015939764


   @rdblue sorry for the delay. I think everything is addressed including the docstrings as per @samredai 


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783354108



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("string", "StringType", is_primitive=True)
+
+
+class UUID(Type):
+    """Universally unique identifiers: `uuid` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("uuid", "UUIDType", is_primitive=True)
+
+
+class Binary(Type):
+    """Arbitrary-length byte array from  https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("binary", "BinaryType", is_primitive=True)
+
+
+BooleanType = Boolean()

Review comment:
       I'm not sure that we need to maintain backward compatibility at this point since there is no expectation that people are using this right now.




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] CircArgs commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
CircArgs commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r787226707



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("string", "StringType", is_primitive=True)
+
+
+class UUID(Type):
+    """Universally unique identifiers: `uuid` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("uuid", "UUIDType", is_primitive=True)
+
+
+class Binary(Type):
+    """Arbitrary-length byte array from  https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("binary", "BinaryType", is_primitive=True)
+
+
+BooleanType = Boolean()

Review comment:
       Okay good to know. I was erring on the safe side. I will keep this in mind as I continue to think about more marginal improvements to types.py




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#issuecomment-1011355682


   Thanks, @CircArgs! I think this is close, but there are minor updates.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783474882



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("string", "StringType", is_primitive=True)
+
+
+class UUID(Type):
+    """Universally unique identifiers: `uuid` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A UUID data type in Iceberg can be represented using an instance of this class. UUIDs in
       Iceberg are universally unique identifiers.
   
       Example:
           >>> column_foo = UUIDType()
           >>> isinstance(column_foo, UUIDType)
           True
       """
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783462839



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A Double data type in Iceberg can be represented using an instance of this class. Doubles in Iceberg are
       64-bit IEEE 754 floating points.
   
       Example:
           >>> column_foo = DoubleType()
           >>> isinstance(column_foo, DoubleType)
           True
       """
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783551019



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       Updated to remove the first line and the `is_primitive` documentation.




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783551019



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       Updated to remove the first line and the `is_primitive` attribute.




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783446761



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A boolean data type in Iceberg can be represented using an instance of this class.
   
       Example:
           >>> column_foo = BooleanType()
           >>> isinstance(column_foo, BooleanType)
           True
   
       Attributes:
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A Date data type in Iceberg can be represented using an instance of this class. Dates in Iceberg are
       calendar dates without a timezone or time.
   
       Example:
           >>> column_foo = DateType()
           >>> isinstance(column_foo, DateType)
           True
   
       Attributes:
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A Long data type in Iceberg can be represented using an instance of this class. Longs in Iceberg are
       64-bit signed integers.
   
       Example:
           >>> column_foo = LongType()
           >>> isinstance(column_foo, LongType)
           True
   
       Attributes:
           max (int): The maximum allowed value for Longs, inherited from the canonical Iceberg implementation
             in Java. (returns `9223372036854775807`)
           min (int): The minimum allowed value for Longs, inherited from the canonical Iceberg implementation
             in Java (returns `-9223372036854775808`)
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A Double data type in Iceberg can be represented using an instance of this class. Doubles in Iceberg are
       64-bit IEEE 754 floating points.
   
       Example:
           >>> column_foo = DoubleType()
           >>> isinstance(column_foo, DoubleType)
           True
   
       Attributes:
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A Float data type in Iceberg can be represented using an instance of this class. Floats in Iceberg are
       32-bit IEEE 754 floating points and can be promoted to Doubles.
   
       Example:
           >>> column_foo = FloatType()
           >>> isinstance(column_foo, FloatType)
           True
   
       Attributes:
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       An Integer data type in Iceberg can be represented using an instance of this class. Integers in Iceberg are
       32-bit signed and can be promoted to Longs.
   
       Example:
           >>> column_foo = IntegerType()
           >>> isinstance(column_foo, IntegerType)
           True
   
       Attributes:
           max (int): The maximum allowed value for Integers, inherited from the canonical Iceberg implementation
             in Java (returns `2147483647`)
           min (int): The minimum allowed value for Integers, inherited from the canonical Iceberg implementation
             in Java (returns `-2147483648`)
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A Timestamp data type in Iceberg can be represented using an instance of this class. Timestamps in
       Iceberg have microsecond precision and include a date and a time of day without a timezone.
   
       Example:
           >>> column_foo = TimestampType()
           >>> isinstance(column_foo, TimestampType)
           True
   
       Attributes:
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A Time data type in Iceberg can be represented using an instance of this class. Times in Iceberg
       have microsecond precision and are a time of day without a date or timezone.
   
       Example:
           >>> column_foo = TimeType()
           >>> isinstance(column_foo, TimeType)
           True
   
       Attributes:
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("string", "StringType", is_primitive=True)
+
+
+class UUID(Type):
+    """Universally unique identifiers: `uuid` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("uuid", "UUIDType", is_primitive=True)
+
+
+class Binary(Type):
+    """Arbitrary-length byte array from  https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A Binary data type in Iceberg can be represented using an instance of this class. Binarys in
       Iceberg are arbitrary-length byte arrays.
   
       Example:
           >>> column_foo = BinaryType()
           >>> isinstance(column_foo, BinaryType)
           True
   
       Attributes:
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A Timestamptz data type in Iceberg can be represented using an instance of this class. Timestamptzs in
       Iceberg are stored as UTC and include a date and a time of day with a timezone.
   
       Example:
           >>> column_foo = TimestamptzType()
           >>> isinstance(column_foo, TimestamptzType)
           True
   
       Attributes:
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       Instead of including the link to the primitive types section of the docstring for each class, I'm realizing it really applies to this entire file so maybe it would be better as a module-level docstring on line 1. Something like this:
   ```py
   """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
   """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("string", "StringType", is_primitive=True)
+
+
+class UUID(Type):
+    """Universally unique identifiers: `uuid` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A UUID data type in Iceberg can be represented using an instance of this class. UUIDs in
       Iceberg are universally unique identifiers.
   
       Example:
           >>> column_foo = UUIDType()
           >>> isinstance(column_foo, UUIDType)
           True
   
       Attributes:
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A primitive data type for an Iceberg schema
   
       A String data type in Iceberg can be represented using an instance of this class. Strings in
       Iceberg are arbitrary-length character sequences and are encoded with UTF-8.
   
       Example:
           >>> column_foo = StringType()
           >>> isinstance(column_foo, StringType)
           True
   
       Attributes:
           is_primitive (bool): Specifies whether this is a primitive Iceberg schema data type (as opposed to a
             nested Iceberg schema data type)
   
       """
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783534464



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       I'm not sure that we need the first line that isn't specific to the type class. The second line seems like a good one though: "A boolean data type in an Iceberg schema"?
   
   Do we need the `is_primitive` documentation? I would expect that to be internal.




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783475352



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("string", "StringType", is_primitive=True)
+
+
+class UUID(Type):
+    """Universally unique identifiers: `uuid` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("uuid", "UUIDType", is_primitive=True)
+
+
+class Binary(Type):
+    """Arbitrary-length byte array from  https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A Binary data type in Iceberg can be represented using an instance of this class. Binarys in
       Iceberg are arbitrary-length byte arrays.
   
       Example:
           >>> column_foo = BinaryType()
           >>> isinstance(column_foo, BinaryType)
           True
       """
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] CircArgs commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
CircArgs commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r777729071



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("string", "StringType", is_primitive=True)
+
+
+class UUID(Type):
+    """Universally unique identifiers: `uuid` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("uuid", "UUIDType", is_primitive=True)
+
+
+class Binary(Type):
+    """Arbitrary-length byte array from  https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("binary", "BinaryType", is_primitive=True)
+
+
+BooleanType = Boolean()

Review comment:
       As not to conflict with the other PR's, I kept the instances at the end of the file so `x == BooleanType` still works. Ultimately, we can refactor elsewhere to use just `isinstance` and then remove these declarations




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] CircArgs commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
CircArgs commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r777729071



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("string", "StringType", is_primitive=True)
+
+
+class UUID(Type):
+    """Universally unique identifiers: `uuid` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("uuid", "UUIDType", is_primitive=True)
+
+
+class Binary(Type):
+    """Arbitrary-length byte array from  https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("binary", "BinaryType", is_primitive=True)
+
+
+BooleanType = Boolean()

Review comment:
       As not to conflict with the other PR's, I kept the instances at the end of the file so `x == BooleanType` still works.




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] CircArgs commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
CircArgs commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r787226707



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("float", "FloatType", is_primitive=True)
+
+
+class Double(Type):
+    """64-bit IEEE 754 floating point: `double` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("double", "DoubleType", is_primitive=True)
+
+
+class Date(Type):
+    """`date` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("date", "DateType", is_primitive=True)
+
+
+class Time(Type):
+    """`time` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("time", "TimeType", is_primitive=True)
+
+
+class Timestamp(Type):
+    """`timestamp` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamp", "TimestampType", is_primitive=True)
+
+
+class Timestamptz(Type):
+    """`timestamptz` type from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("timestamptz", "TimestamptzType", is_primitive=True)
+
+
+class String(Type):
+    """Arbitrary-length character sequences Encoded with UTF-8: `string` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("string", "StringType", is_primitive=True)
+
+
+class UUID(Type):
+    """Universally unique identifiers: `uuid` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("uuid", "UUIDType", is_primitive=True)
+
+
+class Binary(Type):
+    """Arbitrary-length byte array from  https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("binary", "BinaryType", is_primitive=True)
+
+
+BooleanType = Boolean()

Review comment:
       Okay good to know I was airing on the safe side. I will keep this in mind as I continue to think about improvements to types.py




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#issuecomment-1015944268


   Thanks, @CircArgs! I just merged this. Ping me on the next one!


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue merged pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue merged pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839


   


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] rdblue commented on pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
rdblue commented on pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#issuecomment-1015602717


   @CircArgs, I think this is close. Could you update it so we can merge?


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


[GitHub] [iceberg] samredai commented on a change in pull request #3839: Expanding primitive types to individual classes

Posted by GitBox <gi...@apache.org>.
samredai commented on a change in pull request #3839:
URL: https://github.com/apache/iceberg/pull/3839#discussion_r783454000



##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A Long data type in Iceberg can be represented using an instance of this class. Longs in Iceberg are
       64-bit signed integers.
   
       Example:
           >>> column_foo = LongType()
           >>> isinstance(column_foo, LongType)
           True
   
       Attributes:
           max (int): The maximum allowed value for Longs, inherited from the canonical Iceberg implementation
             in Java. (returns `9223372036854775807`)
           min (int): The minimum allowed value for Longs, inherited from the canonical Iceberg implementation
             in Java (returns `-9223372036854775808`)
       """
   ```

##########
File path: python/src/iceberg/types.py
##########
@@ -157,15 +157,107 @@ def value(self) -> NestedField:
         return self._value_field
 
 
-BooleanType = Type("boolean", "BooleanType", is_primitive=True)
-IntegerType = Type("int", "IntegerType", is_primitive=True)
-LongType = Type("long", "LongType", is_primitive=True)
-FloatType = Type("float", "FloatType", is_primitive=True)
-DoubleType = Type("double", "DoubleType", is_primitive=True)
-DateType = Type("date", "DateType", is_primitive=True)
-TimeType = Type("time", "TimeType", is_primitive=True)
-TimestampType = Type("timestamp", "TimestampType", is_primitive=True)
-TimestamptzType = Type("timestamptz", "TimestamptzType", is_primitive=True)
-StringType = Type("string", "StringType", is_primitive=True)
-UUIDType = Type("uuid", "UUIDType", is_primitive=True)
-BinaryType = Type("binary", "BinaryType", is_primitive=True)
+class Boolean(Type):
+    """`boolean` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    def __init__(self):
+        super().__init__("boolean", "BooleanType", is_primitive=True)
+
+
+class Integer(Type):
+    """32-bit signed integers: `int` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 2147483647
+
+    min: int = -2147483648
+
+    def __init__(self):
+        super().__init__("int", "IntegerType", is_primitive=True)
+
+
+class Long(Type):
+    """64-bit signed integers: `long` from https://iceberg.apache.org/#spec/#primitive-types"""
+
+    max: int = 9223372036854775807
+
+    min: int = -9223372036854775808
+
+    def __init__(self):
+        super().__init__("long", "LongType", is_primitive=True)
+
+
+class Float(Type):
+    """32-bit IEEE 754 floating point: `float` from https://iceberg.apache.org/#spec/#primitive-types"""

Review comment:
       ```py
       """A Float data type in Iceberg can be represented using an instance of this class. Floats in Iceberg are
       32-bit IEEE 754 floating points and can be promoted to Doubles.
   
       Example:
           >>> column_foo = FloatType()
           >>> isinstance(column_foo, FloatType)
           True
       """
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org