我需要在帶有分區的配置單元查詢中使用'!='符號。 我試過類似在配置單元查詢中使用不等號符號
from sample_table
insert overwrite table sample1
partition (src='a')
select * where act=10
insert overwrite table sample1
partition (src!='a')
select * where act=20
但它顯示'!='符號錯誤。我如何替換!=
我需要在帶有分區的配置單元查詢中使用'!='符號。 我試過類似在配置單元查詢中使用不等號符號
from sample_table
insert overwrite table sample1
partition (src='a')
select * where act=10
insert overwrite table sample1
partition (src!='a')
select * where act=20
但它顯示'!='符號錯誤。我如何替換!=
嘗試在配置單元中使用rlike/regex函數來指定條件。
我想你也可以使用不操作<>
沒有!=
partition (src!='a')
- 你期望Hive做什麼 - 將「select *」結果寫入任何分區而不是「a」?您看到,partition (src='a')
表示您正在將後續select語句的結果寫入名爲「a」的表分區中。 「PARTITION(a = b)」不是像「WHERE a = b」這樣的條件命令,只是指定如何命名分區。 你剛纔指定另一個分區名稱,所以您的查詢應該是這樣的:
from sample_table insert overwrite table sample1 partition (src='a') select * where act=10 insert overwrite table sample1 partition (src='b') select * where act=20;
之後,你應該看到表「樣本」 2個新分區「A」和「B」從一些數據這些分別是select * where act=10
和select * where act=20
查詢。
可我知道你的蜂巢版本? 嘗試使用<>乙
說明從蜂巢DOCS: NULL,如果A或B是NULL,TRUE,如果表達式A不等於表達式B,否則爲FALSE。