-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(superset): Add patch that fixes saved queries export (#539)
* feat(superset): Add patch that fixes saved queries export * changelog * Add empty folder for 2.1.0 and 2.1.1 * Add findutils explanation * Update superset/Dockerfile Co-authored-by: Lars Francke <lars.francke@stackable.tech> --------- Co-authored-by: Lars Francke <lars.francke@stackable.tech>
- Loading branch information
Showing
6 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
24 changes: 24 additions & 0 deletions
24
superset/stackable/patches/3.0.1/001-26885-query-export-fix.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/superset/queries/saved_queries/commands/export.py b/superset/queries/saved_queries/commands/export.py | ||
index a8fa8acbf..074a4ace2 100644 | ||
--- a/superset/queries/saved_queries/commands/export.py | ||
+++ b/superset/queries/saved_queries/commands/export.py | ||
@@ -40,11 +40,16 @@ class ExportSavedQueriesCommand(ExportModelsCommand): | ||
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" | ||
+ 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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Enable error handling and unset variable checking | ||
set -eu | ||
set -o pipefail | ||
|
||
# Check if $1 (VERSION) is provided | ||
if [ -z "${1-}" ]; then | ||
echo "Please provide a value for VERSION as the first argument." | ||
exit 1 | ||
fi | ||
|
||
VERSION="$1" | ||
PATCH_DIR="patches/$VERSION" | ||
|
||
# Check if version-specific patches directory exists | ||
if [ ! -d "$PATCH_DIR" ]; then | ||
echo "Patches directory '$PATCH_DIR' does not exist." | ||
exit 1 | ||
fi | ||
|
||
# Create an array to hold the patches in sorted order | ||
declare -a patch_files=() | ||
|
||
echo "Applying patches from ${PATCH_DIR}" now | ||
|
||
# Read the patch files into the array | ||
while IFS= read -r -d $'\0' file; do | ||
patch_files+=("$file") | ||
done < <(find "$PATCH_DIR" -name "*.patch" -print0 | sort -zV) | ||
|
||
echo "Found ${#patch_files[@]} patches, applying now" | ||
|
||
# Iterate through sorted patch files | ||
for patch_file in "${patch_files[@]}"; do | ||
echo "Applying $patch_file" | ||
# We can not use Git here, as we are not within a Git repo | ||
cat "$patch_file" | patch --directory "/stackable/app/lib/python${PYTHON}/site-packages" --strip=1 || { | ||
echo "Failed to apply $patch_file" | ||
exit 1 | ||
} | ||
done | ||
|
||
echo "All patches applied successfully." |