Skip to content

Conversation

@fivetran-felixhuang
Copy link
Collaborator

https://docs.snowflake.com/en/sql-reference/functions/booland

https://duckdb.org/docs/stable/sql/expressions/logical_operators

Snowflake's BOOLAND operates on numeric types and NULL, while DuckDB's AND operates on boolean values and NULL.

If we transform each argument expr for the Snowflake BOOLAND to expr == NULL ? NULL : expr != 0, we can use DuckDB's built in AND operator to do the rest

Copy link
Collaborator

@VaggelisD VaggelisD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while DuckDB's AND operates on boolean values and NULL

Why is that the case? The previous transpilation looks fine:

snowflake> SELECT BOOLAND(1, -2), BOOLAND(12, 0), BOOLAND(4, NULL);
TRUE | FALSE | NULL



D SELECT ((1) AND (-2)), (12 AND 0), (4 AND NULL);
┌────────────┬────────────┬──────────────┐
│ (1 AND -2) │ (12 AND 0) │ (4 AND NULL) │
│  booleanbooleanboolean    │
├────────────┼────────────┼──────────────┤
│ true       │ false      │ NULL         │
└────────────┴────────────┴──────────────┘

@fivetran-felixhuang
Copy link
Collaborator Author

while DuckDB's AND operates on boolean values and NULL

Why is that the case? The previous transpilation looks fine:

snowflake> SELECT BOOLAND(1, -2), BOOLAND(12, 0), BOOLAND(4, NULL);
TRUE | FALSE | NULL



D SELECT ((1) AND (-2)), (12 AND 0), (4 AND NULL);
┌────────────┬────────────┬──────────────┐
│ (1 AND -2) │ (12 AND 0) │ (4 AND NULL) │
│  booleanbooleanboolean    │
├────────────┼────────────┼──────────────┤
│ true       │ false      │ NULL         │
└────────────┴────────────┴──────────────┘

You are right, the transpilation works already. I assumed that DuckDB's AND operator only works on boolean values

@georgesittas georgesittas deleted the transpilation_boolan_snowflake_duckDB branch December 11, 2025 14:48
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.

3 participants