lancedb/lancedb · error · TypeError
Unknown data type . Supported types: list of dicts, pandas…
Error message
Unknown data type {type(data)}. Supported types: list of dicts, pandas DataFrame, polars DataFrame, pyarrow Table/RecordBatch, or Pydantic models. See https://docs.lancedb.com/tables/ for examples. What it means
data_to_reader dispatches on the type of `data` and raises TypeError when the value matches none of the supported input types. LanceDB only converts list-of-dicts, pandas DataFrames, polars DataFrames, pyarrow Table/RecordBatch/RecordBatchReader, Pydantic models, and generic Iterables (with a schema). Anything else (str, int, bytes, ndarray, dict, etc.) is rejected.
Solutions
- Convert to a supported type first: pa.Table.from_pandas(df), pd.DataFrame(rows), or a list of dicts
- For a NumPy array, wrap it: pa.table({'col': arr}) or pd.DataFrame(arr)
- For a single dict, wrap it in a list: db.create_table('t', data=[row])
- For other frameworks (HuggingFace Datasets, Dask), convert to arrow/pandas before passing
- If it's an Iterable, supply schema=<pyarrow schema> so data_to_reader takes the iterable branch
Example fix
// before
import numpy as np
arr = np.random.rand(10, 8)
db.create_table('t', data=arr) # TypeError
// after
import pyarrow as pa
db.create_table('t', data=pa.table({'vec': arr.tolist()})) Defensive patterns
Strategy: type-guard
Validate before calling
SUPPORTED = (list, 'pandas.DataFrame', 'polars.DataFrame', 'pyarrow.Table', 'pyarrow.RecordBatch', 'pyarrow.RecordBatchReader')
import pyarrow as pa
ok = isinstance(data, (list, pa.Table, pa.RecordBatch, pa.RecordBatchReader)) or type(data).__name__ in ('DataFrame',) Type guard
def is_supported_data(data) -> bool:
import pyarrow as pa
if isinstance(data, (list, pa.Table, pa.RecordBatch, pa.RecordBatchReader)):
return True
mod = type(data).__module__
return type(data).__name__ == 'DataFrame' and mod.startswith(('pandas', 'polars')) Try / catch
try:
db.create_table('t', data=data)
except TypeError as e:
if 'Unknown data type' in str(e):
db.create_table('t', data=pa.Table.from_pandas(pd.DataFrame(data))) Prevention
- Convert third-party frames (NumPy, HuggingFace, Dask) to pandas/pyarrow before passing
- Wrap single records in a list
- Add a unit test asserting the data type your pipeline produces is accepted
When it happens
Trigger: Passing an unsupported object to create_table's data parameter, e.g. `db.create_table('t', data=multiline_string)`, a single dict instead of a list, a NumPy array, or a dict-of-lists.
Common situations: Copy-pasting CSV/JSON text as data; passing a dict of column arrays from another framework; accidentally passing a file path string instead of reading it; passing a HuggingFace Dataset or Dask/Spark frame not supported by this overload.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- columns must be a list of column names or a dict
- config must be an instance of IvfSq, IvfPq, IvfRq, HnswPq…
- create_function_async requires a @udf definition
- dict values must be str or Expr, got
- Each input should be either str, bytes, Path or Image.
AI-assisted analysis of lancedb/lancedb@c7b051aff7 (2026-09-08).
Data as JSON: /api/errors/da7b09cf5aae6c4e.
Report an issue: GitHub.
Appendix: source
Thrown at python/python/lancedb/common.py:95
return data.to_reader()
elif isinstance(data, pa.RecordBatchReader):
return data
elif (
type(data).__module__.startswith("polars")
and data.__class__.__name__ == "DataFrame"
):
return data.to_arrow().to_reader()
# for other iterables, assume they are of type Iterable[RecordBatch]
elif isinstance(data, Iterable):
if schema is not None:
data = _casting_recordbatch_iter(data, schema)
return pa.RecordBatchReader.from_batches(schema, data)
else:
raise ValueError(
"Must provide schema to write dataset from RecordBatch iterable"
)
else:
raise TypeError(
f"Unknown data type {type(data)}. "
"Supported types: list of dicts, pandas DataFrame, polars DataFrame, "
"pyarrow Table/RecordBatch, or Pydantic models. "
"See https://docs.lancedb.com/tables/ for examples."
)
def validate_schema(schema: pa.Schema):
"""
Make sure the metadata is valid utf8
"""
if schema.metadata is not None:
_validate_metadata(schema.metadata)
def _validate_metadata(metadata: dict):
"""
Make sure the metadata values are valid utf8 (can be nested)View on GitHub (pinned to c7b051aff7)