Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[b/330573524] Prevent IF from treating NULL as FALSE
Tableau offers the IIF function with the signature IIF(bool, val1, val2[, val3]). If bool is TRUE, it returns val1, if it is FALSE, it returns val2, and if it is NULL, it returns val3 if provided, otherwise it returns NULL. Previously, we translated this behavior by rewriting it as BigQuery's IF. The issue however, is that if bool is NULL, BigQuery defaults to val2 instead of NULL or val3. This commit corrects for that by wrapping the expression in another IF that checks if bool is NULL. If it is, it returns val3 if specified, otherwise NULL. If bool is not null, it follows normal IF behavior.
- Loading branch information