我有一个与postgresql等价的查询:
>> select md5('hello')
5d41402abc4b2a76b9719d911017c592
>> select md5('hello')='5d41402abc4b2a76b9719d911017c592'
True我正在尝试对trino引擎进行类似的查询。
>> select md5('hello')
Unexpected parameters (varchar(5)) for function md5. Expected: md5(varbinary) io.trino.spi.TrinoException: Unexpected parameters (varchar(5)) for function md5. Expected: md5(varbinary)因此,我传递了一个varbinary值,类似于:
>> select md5(cast('hello' as varbinary))
OR
>> select md5(to_utf8('hello'))
5d41402a-bc4b-2a76-b971-9d911017c592 << ignore the hyphens for now
``
Now I'm trying to compare this encoded string with previous `md5` expression:选择md5(to_utf8('hello'))='5d41402a-bc4b-2a76-b971-9d911017c592'的
不能应用运算符:varbinary= varchar(36) io.trino.spi.TrinoException:函数$operator$equal的意外参数(var二进制,varchar(36))。预期:$operator$equal(T,T) T:可比
This again shows the operator error.
How do I get this value as a string?
I tried `select from_utf8(md5(to_utf8('hello')))` and it gives this weird output:
]A@*�K*v�q��Œ发布于 2022-09-15 15:32:04
我能够测试并发现返回的字符串是base64,您需要一个十六进制值给compare.Try,将md5()的值传递给to_hex(),这样就可以了。
select to_hex(md5(to_utf8('hello')))='5D41402ABC4B2A76B9719D911017C592'产出:
_col0
truehttps://stackoverflow.com/questions/73733302
复制相似问题