Where condition (in Hue Hive)
…
and col1 IN (‘val1’, ‘val2’)
and (col2 NOT IN (‘valcol’) if col1 = ‘Val1’)
…
The syntax is not correct ? Can you help me ? Thank you
Hi @pql ,
I should say upfront that I personally have no experience of Hue Hive, but if that query is anything like regular sql-like query languages I’m used to, are you sure that “if col1…” clause is correct? Should that not be an “and” or “or” statement maybe?
Thank you very much for your answer takbb, maybe I’ve found something with CASE I have to try it
It seems to be but I am not sure :
…
and CASE
WHEN col1 IN (‘val1’, ‘val2’) THEN col2 NOT IN (‘valcol’)
END
@pql welcome to the online forum.
In Hive you would just use the common case when syntax
CASE
WHEN condition1 THEN result1
WHEN condition2 THEN result2
WHEN conditionN THEN resultN
ELSE result
END AS your_variable
https://www.w3schools.com/sql/sql_case.asp
You also could use where syntax if you want to set a condition on a data table and structure it with brackets and AND and OR syntax. Lists with IN () are also possible.
Also there is a short syntax for conditions with
if(x=y,'this if true','this if false')
thank you, it is ok
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.