Latest Results
fix: IsIn/Decimal/UnresolvedColumn expressions fail to translate to SQL (#7278)
## Changes Made
This fixes two gaps in the SQL expression translation layer
(`Expr::to_sql` / `Literal::display_sql`) and extends column support,
each of which silently degrades filter pushdown or causes SQL syntax
errors when using `read_sql()` with partition bounds or filtered reads.
**IsIn expression translation** (`src/daft-dsl/src/expr/mod.rs`):
`Expr::IsIn` was in the "unsupported" catch-all branch and returned
`None`, so filters like `col("x").is_in([1, 2, 3])` could never be
pushed down — every `read_sql` call with such a filter fell back to a
full table scan with in-memory filtering. Implemented standard `col IN
(v1, v2, v3)` generation. Empty `is_in([])` emits `(1 = 0)`
(constant-false) rather than invalid `IN ()`.
**Decimal literal translation** (`src/daft-core/src/lit/mod.rs`):
Decimal literals were in the unsupported branch. Now use the existing
`display_decimal128` helper. Negative scale values return an explicit
error rather than panicking.
**Unresolved column support** (`src/daft-dsl/src/expr/mod.rs`):
`Column::Unresolved` was previously skipped. Real-world column
references are often unresolved at the point `to_sql()` is called, so
`to_sql()` now handles both `Resolved` and `Unresolved` columns. All
column identifiers are quoted with SQL-standard double quotes to handle
spaces, reserved words, and special characters; `sqlglot` re-renders in
the target dialect during the parse→render round-trip.
**Note on Utf8 single-quote escaping**: Handled separately by PR #7269.
## Testing
Added `tests/io/test_sql_translation.py` covering:
- **Decimal literals**: simple, integer, scientific notation
- **Uuid limitation**: documents that Python `uuid.UUID` does not map to
`Lit::Uuid` (Arrow/Iceberg path only)
- **IsIn**: integers, strings, single item, empty list `(1 = 0)`
- **Identifier quoting**: spaces (`full name`), embedded double quotes
(`x"y` → `"x""y"`), hyphens (`my-col`), reserved words (`SELECT`), and a
`construct_sql_query()` round-trip through sqlglot MySQL dialect
- **Binary/unary operators**: `=`, `!=`, `<`, `<=`, `>`, `>=`, `AND`,
`OR`, `NOT`, `IS NULL`, `IS NOT NULL`
Rust unit tests in `lit/mod.rs` cover Decimal (positive/zero/negative
scale) and Uuid display. All existing tests pass.
## Related Issues
Closes #7197
---------
Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com> Latest Branches
+1%
slade/upgrade-rust-nightly 0%
desmond/azure-sdk-ga-migration 0%
© 2026 CodSpeed Technology