Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[b/330573524] Prevent IF from treating NULL as FALSE #49

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

tanclary
Copy link
Collaborator

@tanclary tanclary commented Mar 27, 2024

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.

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.
@olivrlee olivrlee self-requested a review March 27, 2024 18:56
@tanclary tanclary merged commit 8dc113a into looker-open-source:connector Mar 28, 2024
15 of 16 checks passed
@tanclary tanclary deleted the correct-iif branch March 28, 2024 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants