Hive uses IF(condition, expression, expression), so when I want to do if / else if / else if / else, I have to do:
IF(a, 1, IF(b, 2, IF(c, 3, 4)))
Is there a better way to do this that's more readable?
Looking for something similar to the standard
if (a) {
1
} else if (b) {
2
} else if (c) {
3
} else {
4
}
You can use Hive Conditional
CASE WHEN
function for if-else scenario. TheCASE Statement
will provide you better readability with the same functionality.The best way to handle if else will be to write customize UDF for particular column.