gpt4 book ai didi

sql - 如何检查 hive 中的一串日期时间是否符合要求?

转载 作者:行者123 更新时间:2023-12-02 21:39:01 27 4
gpt4 key购买 nike

我在 hive 中有一张 table :

# the description of table
desc baseinfo;

cv_id string None
cv_update string None
......

# data in table is like this
select cv_id, cv_update from baseinfo limit 1;

00001 2015-04-15 16:34:44

我想做的是:
我想检查 cv_update 是否为 Null 并且它应该满足格式要求,如下所示:
# is_format doesn't exist actually
SELECT cv_id, cv_update FROM baseinfo WHERE cv_update is NOT NULL AND cv_update.is_format("%Y-%m-%d %H:%M:%S")

最佳答案

好吧,这对我来说听起来是一个更好的选择..

示例查询:

SELECT cv_id, cv_update 
FROM baseinfo b
WHERE b.cv_update IS NOT NULL. and CAST(b.cv_update AS TIMESTAMP) IS NOT NULL.

关于sql - 如何检查 hive 中的一串日期时间是否符合要求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30081369/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com