vi_ral
vi_ral

Reputation: 369

hive string comparison is not returning any values

When trying to select only columns where a string is equal to a value in Hive I am returned an empty value.

The schema of the table is as follows:

DESCRIBE table_name;
a                       string                                  
b                       int                                     
c                       int

The contents of the table are as follows:

SELECT * FROM table_name;
"more"  10  30
"dur"   11  30
"vowww" 13  30

Now I try to query for where a="more"

The SELECT ... WHERE query I am running is:

SELECT * FROM table_name WHERE a='more'

The returned value is empty

I have also tried:

To see if double quotes work, if querying for other column values work (it doesnt)

Upvotes: 0

Views: 6269

Answers (2)

saravanatn
saravanatn

Reputation: 630

1st try wild card to see whether it is fetching records or not

SELECT * FROM table_name WHERE a like '%more%'

then if it is fetching records

SELECT * FROM table_name WHERE a='"more"'

Upvotes: 1

Abdelrahman Maharek
Abdelrahman Maharek

Reputation: 872

The result of your Query is:

SELECT * FROM table_name;
"more"  10  30
"dur"   11  30
"vowww" 13  30

This query will return the proper values:

SELECT * FROM table_name WHERE a='"more"'

you should remove the " using regex. Please consider reading this answer Values inserted in hive table with double quotes for string from csv file

Upvotes: 1

Related Questions