{"record":{"id":"b1caf47e06d0c480","repo":"pola-rs/polars","slug":"dtype-is-unknown-consider-supplying-data-types-fo","errorCode":null,"errorMessage":"dtype is unknown; consider supplying data-types for all operations","messagePattern":"dtype is unknown; consider supplying data-types for all operations","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/series/from.rs","lineNumber":180,"sourceCode":"                if let Some(arr) = chunks[0].as_any().downcast_ref::<FixedSizeBinaryArray>() {\n                    assert_eq!(chunks.len(), 1);\n                    // SAFETY:\n                    // this is highly unsafe. it will dereference a raw ptr on the heap\n                    // make sure the ptr is allocated and from this pid\n                    // (the pid is checked before dereference)\n                    {\n                        let pe = PolarsExtension::new(arr.clone());\n                        let s = pe.get_series(&name);\n                        pe.take_and_forget();\n                        s\n                    }\n                } else {\n                    unsafe { get_object_builder(name, 0).from_chunks(chunks) }\n                }\n            },\n            Null => new_null(name, &chunks),\n            Unknown(_) => {\n                panic!(\"dtype is unknown; consider supplying data-types for all operations\")\n            },\n            #[allow(unreachable_patterns)]\n            _ => unreachable!(),\n        }\n    }\n\n    /// # Safety\n    /// The caller must ensure that the given `dtype` matches all the `ArrayRef` dtypes.\n    pub unsafe fn _try_from_arrow_unchecked(\n        name: PlSmallStr,\n        chunks: Vec<ArrayRef>,\n        dtype: &ArrowDataType,\n    ) -> PolarsResult<Self> {\n        Self::_try_from_arrow_unchecked_with_md(name, chunks, dtype, None)\n    }\n\n    /// Create a new Series without checking if the inner dtype of the chunks is correct\n    ///","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/series/from.rs#L162-L198","documentation":"`Series::from_chunks_and_dtype_unchecked` matches on the provided DataType; `DataType::Unknown(_)` is a placeholder dtype (e.g. from lazily-typed or not-yet-resolved sources) and materializing chunks with an unknown dtype is invalid, so it panics telling the caller to supply concrete data types. It is a misuse of an unchecked constructor rather than a recoverable data error.","triggerScenarios":"Calling `Series::from_chunks_and_dtype_unchecked(name, chunks, DataType::Unknown)` (or via code paths that propagate an unresolved dtype from scan/arrow metadata); building Series from a lazy plan whose dtype was never resolved.","commonSituations":"Plugin/connector code copying dtypes from untyped Arrow metadata; caching dtype values before schema resolution and reusing them in unchecked constructors; tests that stub dtypes with Unknown.","solutions":["Resolve the dtype before construction — supply a concrete DataType (e.g. Int64, Utf8) to from_chunks_and_dtype_unchecked.","Use a checked constructor like `Series::from_arrow` or `new_series` that infers or validates the dtype.","If the dtype comes from a lazy source, call schema resolution (e.g. `collect_schema()`/`resolve`) before materializing chunks."],"exampleFix":"// before\nlet s = Series::from_chunks_and_dtype_unchecked(\"a\".into(), chunks, DataType::Unknown(None)); // panics\n\n// after\nlet s = Series::from_chunks_and_dtype_unchecked(\"a\".into(), chunks, DataType::Int64);","handlingStrategy":"validation","validationCode":"if matches!(dtype, DataType::Unknown(_)) {\n    panic!(\"resolve dtype before from_chunks_and_dtype_unchecked\"); // or substitute a concrete dtype\n}","typeGuard":"fn is_resolved(dt: &DataType) -> bool {\n    !matches!(dt, DataType::Unknown(_))\n}","tryCatchPattern":null,"preventionTips":["Never feed unresolved/placeholder dtypes into *_unchecked constructors.","Resolve lazy schemas before materializing chunks.","Prefer checked constructors (from_arrow, from_any_values) in connector code."],"tags":["rust","polars","series","unknown-dtype","internal-invariant-violation"],"backgroundTag":"internal-invariant-violation","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"}