【问题标题】:How to do MD5 hashing of as string in athena?如何在雅典娜中对字符串进行 MD5 散列?
【发布时间】:2019-04-17 15:13:04
【问题描述】:

雅典娜中的 MD5 散列函数不适用于字符串。但是,雅典娜的文档显示确实如此:https://docs.aws.amazon.com/redshift/latest/dg/r_MD5.html

不确定我在这里缺少什么。如果我将 varchar 转换为 varbinary,那么生成的哈希值不正确。

收到此错误:


SYNTAX_ERROR: line 1:8: Unexpected parameters (varchar(15)) for function md5. Expected: md5(varbinary)

This query ran against the "temp" database, unless qualified by the query. Please post the error message on our forum or contact customer support with Query Id: dd959e8a-7fa4-4170-8895-ce7cf58be6ea.```

【问题讨论】:

  • 您链接到的文档来自 Redshift,而不是 Athena。

标签: amazon-athena presto


【解决方案1】:

Athena/Presto 中的md5 函数采用二进制输入。您可以使用 to_utf8 函数将字符串转换为 varbinary:

SELECT md5(to_utf8('hello world'))

【讨论】:

    猜你喜欢
    • 2021-11-19
    • 2021-09-28
    • 1970-01-01
    • 2019-03-16
    • 1970-01-01
    • 2021-03-02
    • 1970-01-01
    • 2022-11-08
    • 1970-01-01
    相关资源
    最近更新 更多