{"record":{"id":"da7b09cf5aae6c4e","repo":"lancedb/lancedb","slug":"unknown-data-type-type-data-supported-types-l","errorCode":null,"errorMessage":"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.","messagePattern":"Unknown data type (.+?)\\. Supported types: list of dicts, pandas DataFrame, polars DataFrame, pyarrow Table/RecordBatch, or Pydantic models\\. See https://docs\\.lancedb\\.com/tables/ for examples\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/python/lancedb/common.py","lineNumber":95,"sourceCode":"        return data.to_reader()\n    elif isinstance(data, pa.RecordBatchReader):\n        return data\n    elif (\n        type(data).__module__.startswith(\"polars\")\n        and data.__class__.__name__ == \"DataFrame\"\n    ):\n        return data.to_arrow().to_reader()\n    # for other iterables, assume they are of type Iterable[RecordBatch]\n    elif isinstance(data, Iterable):\n        if schema is not None:\n            data = _casting_recordbatch_iter(data, schema)\n            return pa.RecordBatchReader.from_batches(schema, data)\n        else:\n            raise ValueError(\n                \"Must provide schema to write dataset from RecordBatch iterable\"\n            )\n    else:\n        raise TypeError(\n            f\"Unknown data type {type(data)}. \"\n            \"Supported types: list of dicts, pandas DataFrame, polars DataFrame, \"\n            \"pyarrow Table/RecordBatch, or Pydantic models. \"\n            \"See https://docs.lancedb.com/tables/ for examples.\"\n        )\n\n\ndef validate_schema(schema: pa.Schema):\n    \"\"\"\n    Make sure the metadata is valid utf8\n    \"\"\"\n    if schema.metadata is not None:\n        _validate_metadata(schema.metadata)\n\n\ndef _validate_metadata(metadata: dict):\n    \"\"\"\n    Make sure the metadata values are valid utf8 (can be nested)","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/lancedb/lancedb/blob/c7b051aff7039333a3f61b79217246c27676806a/python/python/lancedb/common.py#L77-L113","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nimport numpy as np\narr = np.random.rand(10, 8)\ndb.create_table('t', data=arr)  # TypeError\n\n// after\nimport pyarrow as pa\ndb.create_table('t', data=pa.table({'vec': arr.tolist()}))","handlingStrategy":"type-guard","validationCode":"SUPPORTED = (list, 'pandas.DataFrame', 'polars.DataFrame', 'pyarrow.Table', 'pyarrow.RecordBatch', 'pyarrow.RecordBatchReader')\nimport pyarrow as pa\nok = isinstance(data, (list, pa.Table, pa.RecordBatch, pa.RecordBatchReader)) or type(data).__name__ in ('DataFrame',)","typeGuard":"def is_supported_data(data) -> bool:\n    import pyarrow as pa\n    if isinstance(data, (list, pa.Table, pa.RecordBatch, pa.RecordBatchReader)):\n        return True\n    mod = type(data).__module__\n    return type(data).__name__ == 'DataFrame' and mod.startswith(('pandas', 'polars'))","tryCatchPattern":"try:\n    db.create_table('t', data=data)\nexcept TypeError as e:\n    if 'Unknown data type' in str(e):\n        db.create_table('t', data=pa.Table.from_pandas(pd.DataFrame(data)))","preventionTips":["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"],"tags":["python","type-error","table-creation","data-conversion"],"backgroundTag":"type-mismatch","analyzedSha":"c7b051aff7039333a3f61b79217246c27676806a","analyzedAt":"2026-09-08T23:42:37.579Z","contentChangedAt":"2026-09-08T23:42:37.579Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}