{"record":{"id":"f22edb094ed8bc2e","repo":"pola-rs/polars","slug":"cannot-combine-snapshot-id-with-from-snapshot-i","errorCode":null,"errorMessage":"cannot combine `snapshot_id` with `from_snapshot_id_exclusive` or `to_snapshot_id_inclusive`","messagePattern":"cannot combine `snapshot_id` with `from_snapshot_id_exclusive` or `to_snapshot_id_inclusive`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/iceberg/functions.py","lineNumber":213,"sourceCode":"\n    if reader_override is not None:\n        msg = \"the `reader_override` parameter of `scan_iceberg()` is considered unstable.\"\n        issue_unstable_warning(msg)\n\n    if fast_deletion_count is not None:\n        msg = \"the `fast_deletion_count` parameter of `scan_iceberg()` is considered unstable.\"\n        issue_unstable_warning(msg)\n    else:\n        fast_deletion_count = False\n\n    if snapshot_id is not None and (\n        from_snapshot_id_exclusive is not None or to_snapshot_id_inclusive is not None\n    ):\n        msg = (\n            \"cannot combine `snapshot_id` with `from_snapshot_id_exclusive` \"\n            \"or `to_snapshot_id_inclusive`\"\n        )\n        raise ValueError(msg)\n\n    table: pyiceberg.table.Table | None = None\n\n    if importlib.util.find_spec(\"pyiceberg.table\") is not None:\n        import pyiceberg.table\n\n        if isinstance(source, pyiceberg.table.Table):\n            table = source\n\n    table_descriptor_ = None\n\n    if table is None:\n        source = str(source)\n        table_descriptor_ = (\n            source  # Inferred as static metadata path\n            if \"/\" in source or \"\\\\\" in source\n            else IcebergCatalogTableDescriptor(\n                table_identifier=source,","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/py-polars/src/polars/io/iceberg/functions.py#L195-L231","documentation":"scan_iceberg supports selecting snapshots either by a single `snapshot_id`, or by an exclusive lower bound and inclusive upper bound (`from_snapshot_id_exclusive` / `to_snapshot_id_inclusive`). Passing `snapshot_id` together with either bound is ambiguous, so a ValueError is raised before any table is loaded.","triggerScenarios":"Calling pl.scan_iceberg(...) with snapshot_id set AND (from_snapshot_id_exclusive set OR to_snapshot_id_inclusive set).","commonSituations":"Refactoring code from single-snapshot reads to range reads (or vice versa) while leaving the old keyword in place; building kwargs dynamically from config where both keys end up populated.","solutions":["Keep only snapshot_id if you want one specific snapshot.","Remove snapshot_id and keep the from/to bounds for a snapshot range read.","If kwargs come from config/dict, filter out mutually exclusive keys before calling scan_iceberg."],"exampleFix":"// before\nlf = pl.scan_iceberg(table, snapshot_id=42, to_snapshot_id_inclusive=99)\n// after\nlf = pl.scan_iceberg(table, to_snapshot_id_inclusive=99)","handlingStrategy":"validation","validationCode":"def validate_iceberg_kwargs(kwargs):\n    if kwargs.get(\"snapshot_id\") is not None and (\n        kwargs.get(\"from_snapshot_id_exclusive\") is not None\n        or kwargs.get(\"to_snapshot_id_inclusive\") is not None\n    ):\n        raise ValueError(\"snapshot_id is mutually exclusive with from/to bounds\")\n    return kwargs","typeGuard":null,"tryCatchPattern":"try:\n    lf = pl.scan_iceberg(source, **kwargs)\nexcept ValueError as e:\n    if \"cannot combine\" in str(e):\n        kwargs.pop(\"snapshot_id\", None)\n        lf = pl.scan_iceberg(source, **kwargs)\n    else:\n        raise","preventionTips":["Pick one snapshot-selection mode per call: id OR range, never both","Filter mutually exclusive keys when building kwargs from config","Centralize scan_iceberg argument construction in one helper"],"tags":["python","iceberg","api-misuse","argument-validation"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"68506541d2de983056c9eb244e1ea05fab377dfc","analyzedAt":"2026-09-10T10:08:55.499Z","contentChangedAt":"2026-09-10T10:08:55.499Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}