Skip to content

Commit

Permalink
integer boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
ohadmata committed Jun 9, 2024
1 parent fb426f1 commit 054dda3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/shmessy/types/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@

class IntegerType(BaseType):
weight = 7
MAX_BOUNDARY: int = 9223372036854775807 # BIGINT max value
MIN_BOUNDARY: int = -9223372036854775807 # BIGINT min value

def validate(self, data: ndarray) -> Optional[InferredField]:
for value in data:
try:
self.cast_value(value)
if value > self.MAX_BOUNDARY or value < self.MIN_BOUNDARY:
logger.debug(
f"Value '{value}' does not match to {self.name} boundaries"
)
return None
except Exception: # noqa
logger.debug(f"Cannot cast the value '{value}' to {self.name}")
return None
Expand Down

0 comments on commit 054dda3

Please sign in to comment.