Dataset.schema(fetch_if_missing: bool = True) Schema | None[source]#

Return the schema of the dataset.


>>> import ray
>>> ds = ray.data.range(10)
>>> ds.schema()
Column  Type
------  ----
id      int64


If this dataset consists of more than a read, or if the schema can’t be determined from the metadata provided by the datasource, or if fetch_if_missing=True (the default), then this operation will trigger execution of the lazy transformations performed on this dataset.

Time complexity: O(1)


fetch_if_missing – If True, synchronously fetch the schema if it’s not known. If False, None is returned if the schema is not known. Default is True.


The ray.data.Schema class of the records, or None if the schema is not known and fetch_if_missing is False.