Skip to main content
Class representing metadata about a dataset including schema information. Instances of DatasetMetadata are created by Squirrels when describing datasets (and as the base for DatasetResult); you should not construct this class directly. If DatasetMetadata is needed for type annotation, it can be imported from the squirrels.types or squirrels module.

Methods

to_json()

Returns the dataset metadata as a JSON-serializable dictionary.
def to_json(self) -> dict:
returns
dict
A dictionary containing dataset metadata with the following structure:

Examples

Here are some common usage patterns for the DatasetMetadata class. It is assumed that the code is running in an async context (e.g. inside an async function or a Jupyter Notebook cell).

Get dataset metadata

from squirrels.types import DatasetMetadata
from squirrels import SquirrelsProject

sqrl = SquirrelsProject()

# Get metadata for a dataset
metadata: DatasetMetadata = sqrl.dataset_metadata("sales_data")

# Access schema information as JSON
schema_json = metadata.to_json()
print(schema_json)
# Output: {'schema': {'fields': [{'name': 'date', 'type': 'date', ...}, ...]}}