Chart Export Serialization#
Chart export in Superset is handled by ExportChartsCommand, which extends the generic ExportModelsCommand base class. Calling run() produces an iterator of (filename, content_callable) tuples that form a ZIP archive: a metadata.yaml header, one YAML file per chart under charts/, and any related dataset and tag YAMLs.
Serialized Fields#
The canonical set of chart fields comes from Slice.export_fields:
| Field | Notes |
|---|---|
slice_name | Chart display name |
description | |
certified_by | |
certification_details | |
datasource_type | Removed post-export (see below) |
datasource_name | Removed post-export (see below) |
viz_type | Visualization type identifier |
params | Full chart config as a JSON blob |
query_context | Serialized query context |
cache_timeout |
These fields are extracted by ImportExportMixin.export_to_dict(), the shared base-class method called with recursive=False, include_defaults=True, export_uuids=True.
After export_to_dict() runs, ExportChartsCommand._file_content() applies two further transformations:
- Key removal —
REMOVE_KEYS = ["datasource_type", "datasource_name", "url_params"]are stripped .datasource_typeanddatasource_nameare redundant oncedataset_uuidis present;url_paramsare environment-local. paramsJSON expansion — Theparamsstring is decoded into a Python dict before YAML serialization, so the chart config is human-readable YAML rather than an escaped JSON string .
Three fields are then appended by the export command itself:
version— always set toEXPORT_VERSION = "1.0.0"dataset_uuid— UUID of the linkedSqlaTable, if presenttags— custom tag names when theTAGGING_SYSTEMfeature flag is enabled
The two fields is_managed_externally and external_url are listed in extra_import_fields — they are accepted on import but are not exported.
color_scheme and Dashboard-Level Metadata#
color_scheme is not a top-level chart field. It is a dashboard-level property, stored in Dashboard.json_metadata and managed through the dashboard DAO . Standalone chart exports do not include it.
A color_scheme key can appear inside the params JSON blob for chart types that support per-chart color theming — this is purely a visualization preference attached to the chart itself, distinct from the palette applied at dashboard level. Because params is exported wholesale, any per-chart color preference round-trips through export/import.
Dashboard-level color schemes are exported only by ExportDashboardsCommand, which serializes Dashboard.export_fields including json_metadata.
Export Flow#
ExportModelsCommand.run()
└─ yields metadata.yaml
└─ for each Slice:
ExportChartsCommand._export(model)
├─ _file_content(model) → charts/<name>.yaml
├─ ExportDatasetsCommand(...) → datasets/<name>.yaml (if export_related)
└─ ExportTagsCommand(...) → tags YAML (if TAGGING_SYSTEM enabled)
Import#
import_chart() in superset/commands/chart/importers/v1/utils.py reverses the process:
- Looks up the chart by
uuid; checks write permissions and ownership before overwriting. - Calls
filter_chart_annotations()— mutatesparamsto keep onlyFORMULA-type annotation layers (EVENT and other types are dropped). - Re-serializes
paramsfrom dict back to a JSON string . - Calls
migrate_chart()to upgrade legacy viz types. - Calls
Slice.import_from_dict(), which gates field acceptance toexport_fields+extra_import_fields— preventing injection of arbitrary columns.
Key Source Files#
| File | Purpose |
|---|---|
superset/commands/chart/export.py | ExportChartsCommand — serialization logic |
superset/commands/export/models.py | ExportModelsCommand — base iterator/dedup logic |
superset/models/slice.py | Slice model, export_fields, extra_import_fields |
superset/models/helpers.py | ImportExportMixin.export_to_dict() / import_from_dict() |
superset/commands/chart/importers/v1/utils.py | import_chart() — deserialization and migration |
superset/utils/dict_import_export.py | EXPORT_VERSION constant |
superset/daos/dashboard.py | Dashboard color_scheme in json_metadata |