{"record":{"id":"711c8a519f44edf0","repo":"pola-rs/polars","slug":"cannot-set-iter-batches-for-self-driver-name-w","errorCode":null,"errorMessage":"Cannot set `iter_batches` for {self.driver_name} without also setting a non-zero `batch_size`","messagePattern":"Cannot set `iter_batches` for (.+?) without also setting a non-zero `batch_size`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/database/_executor.py","lineNumber":251,"sourceCode":"                        \"adbc_driver_manager\" if driver == \"adbc\" else self.driver_name\n                    )\n                    # if the minimum version constraint is not met, try additional\n                    # driver properties with lower constraints\n                    try:\n                        self._check_module_version(driver_to_check, ver)\n                    except ModuleUpgradeRequiredError:\n                        if i < len(driver_properties_list):\n                            continue\n                        raise\n\n                if iter_batches and (\n                    driver_properties[\"exact_batch_size\"] and not batch_size\n                ):\n                    msg = (\n                        f\"Cannot set `iter_batches` for {self.driver_name} \"\n                        \"without also setting a non-zero `batch_size`\"\n                    )\n                    raise ValueError(msg)  # noqa: TRY301\n\n                frames = (\n                    self._apply_overrides(batch, (schema_overrides or {}))\n                    if isinstance(batch, DataFrame)\n                    else self._apply_overrides(\n                        DataFrame(batch), (schema_overrides or {})\n                    )\n                    for batch in self._fetch_arrow(\n                        driver_properties,\n                        iter_batches=iter_batches,\n                        batch_size=batch_size,\n                    )\n                )\n                return frames if iter_batches else next(frames)  # type: ignore[arg-type,return-value]\n        except Exception as err:\n            # eg: valid turbodbc/snowflake connection, but no arrow support\n            # compiled in to the underlying driver (or on this connection)\n            arrow_not_supported = (","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/database/_executor.py#L233-L269","documentation":"Raised by `_from_arrow` in polars' database executor when `iter_batches=True` is requested for a driver whose Arrow interface either doesn't expose exact batch sizes or wasn't given a non-zero `batch_size`. Streaming in batches is only meaningful — and for some drivers only possible — when polars can request a concrete batch size from the driver.","triggerScenarios":"Calling `pl.read_database(query, connection, iter_batches=True)` with an Arrow-capable driver where `driver_properties[\"exact_batch_size\"]` is true (or iter_batches was set) while `batch_size` is None or 0. E.g. `pl.read_database(q, conn, iter_batches=True)` without `batch_size=`.","commonSituations":"Users streaming large result sets with adbc/connectorx drivers, copying the generic iter_batches recipe from docs but forgetting `batch_size`, or passing `batch_size=0` thinking it means 'default'.","solutions":["Pass a positive `batch_size`, e.g. `pl.read_database(query, conn, iter_batches=True, batch_size=10_000)`.","If you don't need streaming, drop `iter_batches=True` and fetch the whole result as one DataFrame.","Check the driver's capabilities: if the driver doesn't support exact batch sizes, avoid `iter_batches` for it."],"exampleFix":"// before\nreader = pl.read_database(query, conn, iter_batches=True)\n// after\nreader = pl.read_database(query, conn, iter_batches=True, batch_size=10_000)","handlingStrategy":"validation","validationCode":"def validate_batch_args(args: dict) -> dict:\n    if args.get(\"iter_batches\") and not args.get(\"batch_size\"):\n        raise ValueError(\"iter_batches=True requires a positive batch_size\")\n    return args\n\nvalidate_batch_args({\"iter_batches\": True, \"batch_size\": 10_000})","typeGuard":"def iter_batches_usable(batch_size: int | None) -> bool:\n    return batch_size is not None and batch_size > 0","tryCatchPattern":"try:\n    df = pl.read_database(query, conn, iter_batches=True, batch_size=batch_size)\nexcept ValueError as e:\n    if \"batch_size\" in str(e):\n        df = pl.read_database(query, conn)  # fallback: single fetch\n    else:\n        raise","preventionTips":["Treat `iter_batches` and `batch_size` as an inseparable pair in wrappers around read_database.","Never pass batch_size=0 as 'default'; omit iter_batches instead.","Document driver-specific batch support in your data-pipeline config schema."],"tags":["polars","database","batching","invalid-arguments","python"],"backgroundTag":"conflicting-config-options","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}