gpt4 book ai didi

hadoop - 配置单元日期格式匹配

转载 作者:行者123 更新时间:2023-12-02 21:00:18 25 4
gpt4 key购买 nike

我如何在Hive查询中匹配特定的日期格式,因为我必须获得那些具有除最大行数以外的日期格式的行。

例如。我的行数最大值具有MM / dd / yyyy的日期格式,我必须列出除上述格式以外的所有行

+----------------------------+--------------------------+--------------------+-----------+
| AllocationActBankAccountID | GiftCardActBankAccountID | UpdateTimeStampUtc | Date |
+----------------------------+--------------------------+--------------------+-----------+
| 14 | 14 | 41:39.8 | 4/19/2016 |
| 14 | 14 | 37:16.4 | 4/20/2016 |
| 14 | 14 | 52:15.2 | 4/21/2016 |
| 14 | 14 | 52:15.2 | 2/11/2019 |
| 14 | 14 | 52:15.2 | 12-Feb-19 |*
| 14 | 14 | 41:39.8 | 2/13/2019 |
+----------------------------+--------------------------+--------------------+-----------+

我想获取*标记数据(日期= 19年2月12日)

最佳答案

select  *
from mytable
Where date not rlike '^([1-9]|1[0-2])/([1-9]|[1-2][0-9]|3[0-1])/(19|20)\\d{2}$'

要么
select  *
from mytable
Where not
(
date rlike '^\\d{1,2}/\\d{1,2}/\\d{4}$'
and cast(split (date,'/')[0] as int) between 1 and 12
and cast(split (date,'/')[1] as int) between 1 and 31
and cast(split (date,'/')[2] as int) between 1900 and 2099
)

要么
select  date
from mytable
Where coalesce(from_unixtime(to_unix_timestamp(date,'M/d/y')),'0000-01-01')
not between date '1900-01-01' and date '2099-12-31'

关于hadoop - 配置单元日期格式匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43448432/

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