SQL / Impala : 如何使用现有列创建列

SQL / Impala : How to create a column using the existing column

我有一个 table 如下所示:

id  |  field_A  |  field_B  
----------------------------
1   |   Brown   |  Black
2   |   Blue    |  White
3   |   Red     |  Black

我需要创建一个 field_C 逻辑:

if (field_A is not null):
    field_C = field_A
else:
    field_C = field_B

可以使用 SQL/Impala 查询来完成吗?如果是这样,正确的方法应该是什么?谢谢!

如果我没记错的话,impala支持case:

selec id, field_a, field_b,
      case when field_a is not null then field_a
           else field_b
      end as field_c
from yourtable