You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add cond/if/in to Query macro, document function pass-through (#32)
Query macro enrichment:
- `cond do ... end` compiles to SQL CASE WHEN ... THEN ... ELSE ... END
- `if(cond, do: x, else: y)` compiles to simple CASE WHEN
- `x in [1, 2, 3]` and `x in ^list` compile to SQL IN (...)
Documentation:
- Expanded Query moduledoc with all operators, conditionals, IN, and
comprehensive DuckDB function examples by category (date, string,
regex, list, struct, math, null, type)
- Updated getting-started guide with cond, if, in, DuckDB functions,
and compute/1 in materialization section
- Updated README with cond/in examples and function pass-through note
52 query tests including happy path, adversarial (SQL injection strings,
null values, many branches), combined cond+in, and DuckDB function
pass-through verification.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,21 @@ min_amount = 500
65
65
Dux.filter(df, amount >^min_amountand status =="active")
66
66
```
67
67
68
-
The `_with` variants accept raw DuckDB SQL for anything the macro doesn't cover:
68
+
All DuckDB functions work inside expressions — `year()`, `lower()`, `coalesce()`, `regexp_matches()`, and [hundreds more](https://duckdb.org/docs/sql/functions/overview). `cond` maps to `CASE WHEN`, `in` maps to `IN`:
69
+
70
+
```elixir
71
+
Dux.mutate(df,
72
+
tier:conddo
73
+
amount >1000->"gold"
74
+
amount >100->"silver"
75
+
true->"bronze"
76
+
end
77
+
)
78
+
79
+
Dux.filter(df, status in ["active", "pending"])
80
+
```
81
+
82
+
The `_with` variants accept raw DuckDB SQL for window functions and other constructs the macro doesn't cover:
69
83
70
84
```elixir
71
85
Dux.mutate_with(df, rank:"ROW_NUMBER() OVER (PARTITION BY dept ORDER BY salary DESC)")
0 commit comments