{"record":{"id":"1e9a7b042bf24c34","repo":"pola-rs/polars","slug":"unexpected-value-for-if-table-exists-if-table","errorCode":null,"errorMessage":"unexpected value for `if_table_exists`: {if_table_exists!r}\n\nChoose one of {'fail', 'replace', 'append'}","messagePattern":"unexpected value for `if_table_exists`: (.+?)\n\nChoose one of (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/dataframe/frame.py","lineNumber":4540,"sourceCode":"                mode = \"create\"\n            elif if_table_exists == \"replace\":\n                if driver_manager_version < (0, 7):\n                    msg = (\n                        \"`if_table_exists = 'replace'` requires ADBC version >= 0.7, \"\n                        f\"found {driver_manager_str_version}\"\n                    )\n                    raise ModuleUpgradeRequiredError(msg)\n                mode = \"replace\"\n            elif if_table_exists == \"append\":\n                # 'append' inserts into an existing table; the table-existence\n                # check below can upgrade this to 'create_append'.\n                mode = \"append\"\n            else:\n                msg = (\n                    f\"unexpected value for `if_table_exists`: {if_table_exists!r}\"\n                    f\"\\n\\nChoose one of {{'fail', 'replace', 'append'}}\"\n                )\n                raise ValueError(msg)\n\n            with (\n                conn if can_close_conn else contextlib.nullcontext(),\n                conn.cursor() as cursor,\n            ):\n                catalog, db_schema, unpacked_table_name = unpack_table_name(table_name)\n                n_rows: int\n\n                # Try to get the name and version of the underlying ADBC driver to help\n                # with error messages and backwards compatibility\n\n                # We can reliably introspect the underlying driver from a URI\n                # We can also introspect instantiated connections when PyArrow is\n                # installed. Otherwise, the underlying driver is unknown\n                # Ref: https://github.com/apache/arrow-adbc/issues/2828\n                if isinstance(connection, str):\n                    adbc_module_name = _get_adbc_module_name_from_uri(connection)\n                    adbc_driver = _import_optional_adbc_driver(","sourceCodeStart":4522,"sourceCodeEnd":4558,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/dataframe/frame.py#L4522-L4558","documentation":"Error \"unexpected value for `if_table_exists`: {if_table_exists!r}\n\nChoose one of {'fail', 'replace', 'append'}\" thrown in pola-rs/polars.","triggerScenarios":"Thrown at py-polars/src/polars/dataframe/frame.py:4540 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}