【问题标题】:AWS Athena query to find Date column has String or not satisfying timestamp format用于查找日期列的 AWS Athena 查询具有字符串或不满足时间戳格式
【发布时间】:2022-11-24 18:44:03
【问题描述】:

我正在 AWS Athena 中测试 Sprak 3 升级,需要检查日期列时间戳格式是否正确,任何人都可以给我查询以检查日期列是否具有时间戳格式以外的任何值

【问题讨论】:

    标签: sql amazon-web-services amazon-athena presto trino


    【解决方案1】:

    假设您有一个 varchar 列,您可以尝试使用 date_parse 包装在 try 中:

    select *
    from table 
    where try(date_parse(string_column, 'your_expected_format')) is null -- assuming no original nulls in column
    

    或者通过 try_cast 获取“标准”格式:

    select *
    from table 
    where try_cast(string_column as timestamp) -- assuming no original nulls in column
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-16
      • 2021-11-02
      • 1970-01-01
      • 2021-02-02
      • 1970-01-01
      • 2020-06-22
      相关资源
      最近更新 更多