Presto 无法读取十六进制字符串:不是有效的 16 进制数字

问题描述 投票:0回答:1

有没有办法让 presto 检查字符串是否是十六进制?我有以下查询一直失败:

from_base(hexstring, 16)

有错误

>     /usr/local/lib/python3.7/dist-packages/pyhive/presto.py in _process_response(self, response)
>     347             self._state = self._STATE_FINISHED
>     348         if 'error' in response_json:
> --> 349             raise DatabaseError(response_json['error'])
>     350 
>     351 
> 
> DatabaseError: {'message': 'Not a valid base-16 number:
> ffffffffffdfae90', 'errorCode': 7, 'errorName':
> 'INVALID_FUNCTION_ARGUMENT', 'errorType': 'USER_ERROR', 'failureInfo':
> {'type': 'io.prestosql.spi.PrestoException', 'message': 'Not a valid
> base-16 number: ffffffffffdfae90', 'cause': {'type':
> 'java.lang.NumberFormatException', 'message': 'For input string:
> "ffffffffffdfae90"', 'suppressed': [], 'stack':
> 

但是,Python 可以处理字符串:

int('ffffffffffdfae90',16)

退货

18446744073707433616
sql presto trino
1个回答
1
投票

from_base
returns
BIGINT
可以容纳
2^63 - 1
9223372036854775807
小于
18446744073707433616
而 python 的
int
是不确定的,所以这个特定的数字对于 Presto 来说太大了。

© www.soinside.com 2019 - 2024. All rights reserved.