COALESCE (Lakehouse v1)
返回其参数中第一个非 NULL 的表达式;如果所有参数均为 NULL,则返回 NULL。
Analyze 语法
Section titled “Analyze 语法”func.coalesce(<expr1>[, <expr2> ...])Analyze 示例
Section titled “Analyze 示例”func.coalesce(table.UOM, 'none', \n)
func.coalesce(get_column(table2, 'TECHNOLOGY_RATE'), 0.0)
func.coalesce(table_beta.adjusted_price, table_alpha.override_price, table_alpha.price) * table_beta.quantity_soldSQL 语法
Section titled “SQL 语法”COALESCE(<expr1>[, <expr2> ...])SQL 示例
Section titled “SQL 示例”SELECT COALESCE(1), COALESCE(1, NULL), COALESCE(NULL, 1, 2);
┌────────────────────────────────────────────────────────┐│ coalesce(1) │ coalesce(1, null) │ coalesce(null, 1, 2) │├─────────────┼───────────────────┼──────────────────────┤│ 1 │ 1 │ 1 │└────────────────────────────────────────────────────────┘
SELECT COALESCE('a'), COALESCE('a', NULL), COALESCE(NULL, 'a', 'b');
┌────────────────────────────────────────────────────────────────┐│ coalesce('a') │ coalesce('a', null) │ coalesce(null, 'a', 'b') │├───────────────┼─────────────────────┼──────────────────────────┤│ a │ a │ a │└────────────────────────────────────────────────────────────────┘