Skip to content

Commit c4b134a

Browse files
sadpandajoeclaude
andcommitted
fix(examples): use backend check instead of hardcoding 'main' schema
Instead of checking if default_schema == 'main', check the database backend to determine if schemas are supported. This is more robust and extensible - just add backends to the no_schema_backends set. Currently only SQLite is in this set, but can easily add others if needed. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent feee7b8 commit c4b134a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

superset/examples/data_loading.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# Import loaders that have custom logic (dashboards, CSS, etc.)
2626
from superset.cli.test_loaders import load_big_data
27-
from superset.utils.core import get_example_default_schema
27+
from superset.utils.core import backend, get_example_default_schema
2828

2929
from .css_templates import load_css_templates
3030

@@ -109,13 +109,18 @@ def _get_multi_dataset_config(
109109
def _get_effective_schema(config_schema: Optional[str]) -> Optional[str]:
110110
"""Get effective schema for data loading, matching import flow behavior.
111111
112-
SQLite's 'main' schema is not a real schema like PostgreSQL's 'public',
113-
so we treat it as None to avoid schema-related SQL errors.
112+
Some databases (SQLite) don't support real schemas - their 'main' is just
113+
an attachment name, not a schema like PostgreSQL's 'public'. For these
114+
backends, we return None to avoid schema-related SQL errors.
114115
"""
116+
# Backends that don't support real schemas
117+
no_schema_backends = {"sqlite"}
118+
115119
if config_schema:
116120
return config_schema
117-
default_schema = get_example_default_schema()
118-
return None if default_schema == "main" else default_schema
121+
if backend() in no_schema_backends:
122+
return None
123+
return get_example_default_schema()
119124

120125

121126
def discover_datasets() -> Dict[str, Callable[..., None]]:

0 commit comments

Comments
 (0)