{"record":{"id":"9d58d093cea7fd99","repo":"pola-rs/polars","slug":"unrecognised-frame-type-qualified-type-name-obj","errorCode":null,"errorMessage":"unrecognised frame type: {qualified_type_name(obj)}","messagePattern":"unrecognised frame type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/sql/context.py","lineNumber":77,"sourceCode":"\n\ndef _ensure_lazyframe(obj: Any) -> LazyFrame:\n    \"\"\"Return LazyFrame from compatible input.\"\"\"\n    if isinstance(obj, (DataFrame, LazyFrame)):\n        return obj.lazy()\n    elif isinstance(obj, Series):\n        return obj.to_frame().lazy()\n    elif _check_for_pandas(obj) and isinstance(obj, (pd.DataFrame, pd.Series)):\n        if isinstance(frame := from_pandas(obj), Series):\n            frame = frame.to_frame()\n        return frame.lazy()\n    elif is_pycapsule(obj) or (\n        _check_for_pyarrow(obj) and isinstance(obj, (pa.Table, pa.RecordBatch))\n    ):\n        return DataFrame(obj).lazy()  # type: ignore[union-attr]\n    else:\n        msg = f\"unrecognised frame type: {qualified_type_name(obj)}\"\n        raise ValueError(msg)\n\n\ndef _get_frame_locals(\n    *,\n    all_compatible: bool,\n    n_objects: int | None = None,\n    named: str | Collection[str] | Callable[[str], bool] | None = None,\n) -> dict[str, Any]:\n    \"\"\"Return compatible frame objects from the local stack.\"\"\"\n    of_type = _compatible_frame if all_compatible else (DataFrame, LazyFrame, Series)\n    return _get_stack_locals(of_type=of_type, n_objects=n_objects, named=named)  # type: ignore[arg-type]\n\n\nclass SQLContext(Generic[FrameType]):\n    \"\"\"\n    Run SQL queries against DataFrame, LazyFrame, and Series data.\n\n    .. warning::","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/sql/context.py#L59-L95","documentation":"SQLContext.register (via _ensure_lazyframe) accepts LazyFrames, DataFrames, and a known set of external objects (pycapsule providers, pyarrow Table/RecordBatch, pandas, etc.). Anything else raises ValueError because it cannot be converted to a LazyFrame for registration.","triggerScenarios":"ctx.register('t', some_numpy_array), registering a polars Series, a pyarrow RecordBatchReader of unsupported kind, a plain list, or an arbitrary Python object.","commonSituations":"Passing a pandas DataFrame after a refactor removed the pandas extra; registering a Spark/DuckDB relation hoping for auto-conversion; accidentally registering the result of df.to_arrow() stored as a batch reader.","solutions":["Convert explicitly first: ctx.register('t', pl.DataFrame(obj)) or pl.from_arrow(obj).lazy().","For pandas, use pl.from_pandas(df).lazy().","If it's already a LazyFrame, register it directly; verify with isinstance(obj, pl.LazyFrame)."],"exampleFix":"# before\nctx.register('tbl', numpy_array)  # ValueError\n\n# after\nctx.register('tbl', pl.DataFrame(numpy_array).lazy())","handlingStrategy":"type-guard","validationCode":"if not isinstance(obj, (pl.LazyFrame, pl.DataFrame, pl.Series)) and not hasattr(obj, '__arrow_c_stream__'):\n    obj = pl.DataFrame(obj).lazy()","typeGuard":"def is_registrable(obj) -> bool:\n    return isinstance(obj, (pl.LazyFrame, pl.DataFrame)) or hasattr(obj, '__arrow_c_stream__')","tryCatchPattern":"try:\n    ctx.register('t', obj)\nexcept ValueError:\n    ctx.register('t', pl.from_arrow(obj).lazy())","preventionTips":["Convert third-party frames (pandas/pyarrow) explicitly with pl.from_* helpers before registering","Keep a single to_lazyframe(obj) utility in your codebase","Check installed extras (pandas, pyarrow) when deployment environments differ from dev"],"tags":["polars","sql","register","type-error"],"backgroundTag":"incompatible-source-type","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"}