Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using not equal symbol in hive query

Tags:

hive

I need to use '!=' symbol in my hive query with partitions. I tried something like

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

But it is showing error at '!=' symbol. How can i replace !=

like image 301
RAVITEJA SATYAVADA Avatar asked Feb 19 '13 10:02

RAVITEJA SATYAVADA


People also ask

How do you find not equal to in Hive?

Hive Relational Operators Returns TRUE when A is equal to B, FLASE when they are not equal. Similar to = operator. Same as = and == operator for non-null values. Returns TRUE if A is not equal to B, otherwise FALSE.

Can we use not in in Hive?

Though the IN operator in hive works just fine in this case as well but NOT IN doesn't. If I replace NOT IN with IN operator, that works. Inact using NOT IN with a list of strings specified works too but it somehow does not work with select statement.

Is in operator in Hive?

Hey, Yes, now Hive supports IN or EXIST, operators.

What is HiveQL?

Hive enables data summarization, querying, and analysis of data. Hive queries are written in HiveQL, which is a query language similar to SQL. Hive allows you to project structure on largely unstructured data. After you define the structure, you can use HiveQL to query the data without knowledge of Java or MapReduce.


1 Answers

Try to use rlike/regex function in hive to specify condition.

I think you can also use not operator <> not !=

like image 119
Balaswamy Vaddeman Avatar answered Oct 10 '22 01:10

Balaswamy Vaddeman