in awswrangler/s3/_write_dataset.py [0:0]
def _get_value_hash(value: str | int | bool) -> int:
if isinstance(value, (int, np.int_)):
value = int(value)
bigint_min, bigint_max = -(2**63), 2**63 - 1
int_min, int_max = -(2**31), 2**31 - 1
if not bigint_min <= value <= bigint_max:
raise ValueError(f"{value} exceeds the range that Athena cannot handle as bigint.")
if not int_min <= value <= int_max:
value = (value >> 32) ^ value
if value < 0:
return -value - 1
return int(value)
if isinstance(value, (str, np.str_)):
value_hash = 0
for byte in value.encode():
value_hash = value_hash * 31 + byte
value_hash = _simulate_overflow(value_hash)
return value_hash
if isinstance(value, (bool, np.bool_)):
return int(value)
raise exceptions.InvalidDataFrame(
"Column specified for bucketing contains invalid data type. Only string, int and bool are supported."
)