2017-04-17 14 views
0

ハイブのクエリで特定の日付の形式に一致させるにはどうすればよいのですか?最大行以外の日付形式の行を取得する必要があります。ハイブ日付の形式の一致

例:行の私の最大は、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 | 
+----------------------------+--------------------------+--------------------+-----------+ 
私が欲しい

に取得*マークされたデータ(日= 12 2月-19)

+0

あなたはなぜ日付/タイムスタンプの種類ではなくISO形式以外の文字列を使用していますか? –

+0

私たちが受け取っているファイルごとです。 –

+1

あなたがここでやろうとしていることがどれほど悪いかを説明することさえできません。それは決して存在しない統合の概念のようなものです。 –

答えて

0
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'