arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject [arrow] branch master updated: ARROW-1791: Limit generated data range to physical limits for temporal types
Date Sat, 18 Nov 2017 05:41:07 GMT
This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 202e650  ARROW-1791: Limit generated data range to physical limits for temporal types
202e650 is described below

commit 202e6503cd2e941a2df2ccacedf09611d8ad2e0f
Author: Wes McKinney <wes.mckinney@twosigma.com>
AuthorDate: Sat Nov 18 00:41:01 2017 -0500

    ARROW-1791: Limit generated data range to physical limits for temporal types
    
    cc @trxcllnt, do these time ranges seem reasonable?
    
    Author: Wes McKinney <wes.mckinney@twosigma.com>
    
    Closes #1328 from wesm/ARROW-1791 and squashes the following commits:
    
    57a117aa [Wes McKinney] Add comment about nanosecond timestamp range
    e20ad490 [Wes McKinney] Also restrict time and timestamp generated integer ranges
    784e7a95 [Wes McKinney] Restrict generated date range in integration tests
---
 integration/integration_test.py | 41 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/integration/integration_test.py b/integration/integration_test.py
index 205176e..46d0106 100644
--- a/integration/integration_test.py
+++ b/integration/integration_test.py
@@ -231,10 +231,19 @@ class DateType(IntegerType):
     DAY = 0
     MILLISECOND = 1
 
+    # 1/1/1 to 12/31/9999
+    _ranges = {
+        DAY: [-719162, 2932896],
+        MILLISECOND: [-62135596800000, 253402214400000]
+    }
+
     def __init__(self, name, unit, nullable=True):
         bit_width = 32 if unit == self.DAY else 64
+
+        min_value, max_value = self._ranges[unit]
         super(DateType, self).__init__(
-            name, True, bit_width, nullable=nullable
+            name, True, bit_width, nullable=nullable,
+            min_value=min_value, max_value=max_value
         )
         self.unit = unit
 
@@ -262,10 +271,19 @@ class TimeType(IntegerType):
         'ns': 64
     }
 
+    _ranges = {
+        's': [0, 86400],
+        'ms': [0, 86400000],
+        'us': [0, 86400000000],
+        'ns': [0, 86400000000000]
+    }
+
     def __init__(self, name, unit='s', nullable=True):
-        super(TimeType, self).__init__(
-            name, True, self.BIT_WIDTHS[unit], nullable=nullable
-        )
+        min_val, max_val = self._ranges[unit]
+        super(TimeType, self).__init__(name, True, self.BIT_WIDTHS[unit],
+                                       nullable=nullable,
+                                       min_value=min_val,
+                                       max_value=max_val)
         self.unit = unit
 
     def _get_type(self):
@@ -278,8 +296,21 @@ class TimeType(IntegerType):
 
 class TimestampType(IntegerType):
 
+    # 1/1/1 to 12/31/9999
+    _ranges = {
+        's': [-62135596800, 253402214400],
+        'ms': [-62135596800000, 253402214400000],
+        'us': [-62135596800000000, 253402214400000000],
+
+        # Physical range for int64, ~584 years and change
+        'ns': [np.iinfo('int64').min, np.iinfo('int64').max]
+    }
+
     def __init__(self, name, unit='s', tz=None, nullable=True):
-        super(TimestampType, self).__init__(name, True, 64, nullable=nullable)
+        min_val, max_val = self._ranges[unit]
+        super(TimestampType, self).__init__(name, True, 64, nullable=nullable,
+                                            min_value=min_val,
+                                            max_value=max_val)
         self.unit = unit
         self.tz = tz
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@arrow.apache.org" <commits@arrow.apache.org>'].

Mime
View raw message