{"record":{"id":"1b7b7a8895eeca28","repo":"pola-rs/polars","slug":"unsupported-null-type-null-type-r","errorCode":null,"errorMessage":"unsupported null type: {null_type!r}","messagePattern":"unsupported null type: (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/interchange/from_dataframe.py","lineNumber":295,"sourceCode":"        return data.is_not_nan()\n\n    elif null_type == ColumnNullType.USE_SENTINEL:\n        if not allow_copy:\n            msg = \"bitmask must be constructed\"\n            raise CopyNotAllowedError(msg)\n\n        sentinel = pl.Series([null_value])\n        try:\n            if column_dtype.is_temporal():\n                sentinel = sentinel.cast(column_dtype)\n            return data != sentinel  # noqa: TRY300\n        except InvalidOperationError as e:\n            msg = f\"invalid sentinel value for column of type {column_dtype}: {null_value!r}\"\n            raise TypeError(msg) from e\n\n    else:\n        msg = f\"unsupported null type: {null_type!r}\"\n        raise NotImplementedError(msg)\n\n\ndef _construct_validity_buffer_from_bitmask(\n    buffer: Buffer,\n    null_value: int,\n    length: int,\n    offset: int = 0,\n    *,\n    allow_copy: bool,\n) -> Series:\n    buffer_info = (buffer.ptr, offset, length)\n    s = pl.Series._from_buffer(Boolean, buffer_info, buffer)\n\n    if null_value != 0:\n        if not allow_copy:\n            msg = \"bitmask must be inverted\"\n            raise CopyNotAllowedError(msg)\n        s = ~s","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/py-polars/src/polars/interchange/from_dataframe.py#L277-L313","documentation":"Polars' interchange importer understands exactly four null representations: USE_BITMAP, USE_BYTEMASK, USE_NAN, and USE_SENTINEL. If a column's describe_null() reports any other ColumnNullType (including None or constants from newer protocol revisions), NotImplementedError('unsupported null type: ...') is raised.","triggerScenarios":"pl.from_dataframe(obj) where describe_null()[0] is outside the four supported values — a buggy producer returning None/0, or a producer built against a newer protocol revision that added a null type this Polars version does not know.","commonSituations":"Version skew: producer library newer than the installed Polars; custom interchange implementations returning a placeholder; producers using the protocol's NONNULL constant incorrectly (it must be handled before buffers are requested).","solutions":["Upgrade Polars to a version that knows the null type.","Fix the producer to report one of USE_BITMAP/USE_BYTEMASK/USE_NAN/USE_SENTINEL (or no nulls at all).","Convert via pyarrow or the producer's native export path instead of the interchange protocol."],"exampleFix":"# producer side, before\n def describe_null(self):\n     return (None, None)  # -> NotImplementedError\n# after\n def describe_null(self):\n     return (ColumnNullType.USE_BITMAP, 0)","handlingStrategy":"validation","validationCode":"SUPPORTED_NULL_TYPES = {\n    ColumnNullType.USE_BITMAP,\n    ColumnNullType.USE_BYTEMASK,\n    ColumnNullType.USE_NAN,\n    ColumnNullType.USE_SENTINEL,\n}\n\nunsupported = [\n    i for i in range(icdf.num_columns())\n    if icdf.get_column(i).describe_null()[0] not in SUPPORTED_NULL_TYPES\n]","typeGuard":null,"tryCatchPattern":"try:\n    df = pl.from_dataframe(obj)\nexcept NotImplementedError as e:\n    if \"unsupported null type\" not in str(e):\n        raise\n    # upgrade Polars, or fix the producer's describe_null() to a supported constant","preventionTips":["Pin producer and consumer protocol versions together; upgrade both in lockstep.","Return one of the four supported null types (or no-nulls) from describe_null()."],"tags":["polars","interchange-protocol","nullability","notimplementederror"],"backgroundTag":"unsupported-null-type","analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}