【问题标题】:Can I coalesce a column in presto DB to get a list of all possible pairs when some might be null?当某些可能为空时,我可以合并 presto DB 中的列以获取所有可能对的列表吗?
【发布时间】:2020-05-22 20:18:27
【问题描述】:

我在 Athena 有一个数据库,假设有一个 countryregiondata 列。

我想获取所有唯一 country/region 对的列表,包括 region 何时可能为空白(这是针对整个国家/地区的数据的情况)。

我尝试了SELECT distinct(country, region) FROM ...,但收到错误NOT_SUPPORTED: ROW comparison not supported for fields with null elements

我认为这可能有效:

SELECT distinct(coalesce(country,"none"), coalesce(region, "none") region) FROM ...

但也没有运气。知道这是否可能吗?

【问题讨论】:

    标签: presto amazon-athena


    【解决方案1】:

    这应该可以工作(不带大括号):

    SELECT DISTINCT country, region FROM ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-15
      • 1970-01-01
      • 1970-01-01
      • 2014-01-09
      • 2021-06-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多