I want to select a data either A column equals 'X' or B column equals 'X' but not both of them equal 'X'. Is there such a function in HQL?
Try below query instead of tablename use your tablename
SELECT * FROM (
SELECT
CASE WHEN COLUMNA='X' AND COLUMNB<>'X' THEN COLUMNA
CASE WHEN COLUMNA<>'X' AND COLUMNB='X' THEN COLUMNB
END AS XORCOMBO
FROM TABLENAME
)X
WHERE XORCOMBO IS NOT NULL
Hive does have bitwise XOR arithmetic operator. It can be used on any numeric data type for ex. A ^ B
.
More details can be found in hive official documentation: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-ArithmeticOperators
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.