Skip to content

Commit feee7b8

Browse files
sadpandajoeclaude
andcommitted
fix(examples): handle SQLite 'main' schema as None
SQLite's 'main' schema is not a real schema like PostgreSQL's 'public'. When get_example_default_schema() returns 'main', treat it as None to avoid "near SCHEMA: syntax error" when loading examples on SQLite. Extracted _get_effective_schema() helper to reduce function complexity. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5869cb3 commit feee7b8

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

superset/examples/data_loading.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ def _get_multi_dataset_config(
106106
return result
107107

108108

109+
def _get_effective_schema(config_schema: Optional[str]) -> Optional[str]:
110+
"""Get effective schema for data loading, matching import flow behavior.
111+
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.
114+
"""
115+
if config_schema:
116+
return config_schema
117+
default_schema = get_example_default_schema()
118+
return None if default_schema == "main" else default_schema
119+
120+
109121
def discover_datasets() -> Dict[str, Callable[..., None]]:
110122
"""Auto-discover all example datasets and create loaders for them.
111123
@@ -141,14 +153,11 @@ def discover_datasets() -> Dict[str, Callable[..., None]]:
141153
logger.warning("data_file '%s' does not exist", explicit_data_file)
142154
resolved_file = data_file
143155

144-
# Use default schema if not specified, matching import flow behavior
145-
schema = config["schema"] or get_example_default_schema()
146-
147156
loader_name = f"load_{dataset_name}"
148157
loaders[loader_name] = create_generic_loader(
149158
dataset_name,
150159
table_name=table_name,
151-
schema=schema,
160+
schema=_get_effective_schema(config["schema"]),
152161
data_file=resolved_file,
153162
uuid=config.get("uuid"),
154163
)
@@ -163,15 +172,12 @@ def discover_datasets() -> Dict[str, Callable[..., None]]:
163172

164173
config = _get_multi_dataset_config(example_dir, dataset_name, data_file)
165174

166-
# Use default schema if not specified, matching import flow behavior
167-
schema = config["schema"] or get_example_default_schema()
168-
169175
loader_name = f"load_{dataset_name}"
170176
if loader_name not in loaders:
171177
loaders[loader_name] = create_generic_loader(
172178
dataset_name,
173179
table_name=config["table_name"],
174-
schema=schema,
180+
schema=_get_effective_schema(config["schema"]),
175181
data_file=config["data_file"],
176182
uuid=config.get("uuid"),
177183
)

0 commit comments

Comments
 (0)