Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow exporting saved queries without schema information #26889

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions superset/commands/query/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@
def _export(
model: SavedQuery, export_related: bool = True
) -> Iterator[tuple[str, str]]:
# build filename based on database, optional schema, and label
# build filename based on database, optional schema, and label.
# we call secure_filename() multiple times and join the directories afterwards,
# as secure_filename() replaces "/" with "_".
database_slug = secure_filename(model.database.database_name)
schema_slug = secure_filename(model.schema)
query_slug = secure_filename(model.label) or str(model.uuid)
file_name = f"queries/{database_slug}/{schema_slug}/{query_slug}.yaml"
if model.schema is None:
file_name = f"queries/{database_slug}/{query_slug}.yaml"

Check warning on line 49 in superset/commands/query/export.py

View check run for this annotation

Codecov / codecov/patch

superset/commands/query/export.py#L49

Added line #L49 was not covered by tests
else:
schema_slug = secure_filename(model.schema)
file_name = f"queries/{database_slug}/{schema_slug}/{query_slug}.yaml"

payload = model.export_to_dict(
recursive=False,
Expand Down
Loading