fix: handle zero-column DuckDB sources - #493
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
LGTM ! Just need to sort out the failing CI. @kevincostner17 , could you review? |
…fallback The zero-column short-circuit ran ahead of the backend's fallback chain, so it bypassed both `pandas_ingest_fallback_reason` and `_pandas_index_forces_fallback`. Three consequences: - A zero-column frame with a non-RangeIndex worked before this change (the index guard routed it to pandas and the labels survived) and came back with a rebuilt RangeIndex after it, silently dropping the labels and breaking the parity the `native_config` fixture exists to enforce. - `output_format="duckdb"` still raised, now a RuntimeError from `_require_recorded_fallback`, since a materialized frame may stand in for a native handle only after a fallback the report discloses. - `rows_before=len(source)` is only meaningful for pandas: a zero-column LazyFrame raised TypeError and a parquet path would have passed its character count off as a row count. A source DuckDB cannot register is an ingest limitation, so name it as one and let the existing chain handle it. The pandas reference already keeps the rows and the index on a zero-column frame, and the fallback is disclosed in the report and still blocked by `fallback_policy="error"`. Fixes FreshCode-Org#457 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
3e2642b to
c49cb46
Compare
|
Thanks for this — the bug is real and your diagnosis of it was right. I've pushed a commit to your branch (and rebased onto current The short-circuit sat ahead of the backend's fallback chain, so it jumped over both 1. A zero-column frame with a non-RangeIndex regressed. This case wasn't broken before — the index guard already routed it to the pandas reference and the labels survived:
2. 3. The fix follows from (2): a source DuckDB cannot register is an ingest limitation, so it belongs in the reason chain rather than in front of it. reason = plan.fallback_reason or pandas_ingest_fallback_reason(source, self.name)
if reason is None and not plan_cols:
reason = "zero-column source"
if reason is None and self._pandas_index_forces_fallback(source):Six lines with the comment, no new import, no Your regression test is kept, with three added alongside it: the disclosed fallback, index preservation checked against Verified locally: |
Description
Handle zero-column pandas DataFrames in the DuckDB backend without raising an error.
Fixes #457
Type of Change
Tests Performed
pytest tests\test_execution\test_duckdb_engine.py --no-cov12 passedgit diff --checkpassed(3, 0)(3, 0)duckdb.InvalidInputException