diff --git a/CHANGELOG.md b/CHANGELOG.md index ea75321df..0087c1fc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. - ubi8-rust-builder: bump rust toolchain to `1.75.0` ([#542], [#517]). - GH workflows: make preflight an independent manual workflow and update to version 1.7.2 ([#519]). - hadoop: Build from source ([#526]). +- superset: Add patch that fixes saved queries export ([#539]). [#493]: https://github.com/stackabletech/docker-images/pull/493 [#506]: https://github.com/stackabletech/docker-images/pull/506 @@ -33,6 +34,7 @@ All notable changes to this project will be documented in this file. [#536]: https://github.com/stackabletech/docker-images/pull/536 [#537]: https://github.com/stackabletech/docker-images/pull/537 [#538]: https://github.com/stackabletech/docker-images/pull/538 +[#539]: https://github.com/stackabletech/docker-images/pull/539 [#542]: https://github.com/stackabletech/docker-images/pull/542 ## [23.11.0] - 2023-11-30 diff --git a/superset/Dockerfile b/superset/Dockerfile index f82741290..40740e5e1 100644 --- a/superset/Dockerfile +++ b/superset/Dockerfile @@ -17,6 +17,8 @@ RUN microdnf update \ && microdnf install \ --assumeyes \ cyrus-sasl-devel \ + # Needed to find all patch files, used in `apply_patches.sh` + findutils \ gcc \ gcc-c++ \ libffi-devel \ @@ -57,6 +59,9 @@ RUN microdnf update \ python-json-logger \ && if [ ! -z "$AUTHLIB" ]; then pip install Authlib==${AUTHLIB}; fi +COPY superset/stackable/patches /patches +RUN /patches/apply_patches.sh ${PRODUCT} + # Final image FROM stackable/image/vector diff --git a/superset/stackable/patches/2.1.0/.gitignore b/superset/stackable/patches/2.1.0/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/superset/stackable/patches/2.1.1/.gitignore b/superset/stackable/patches/2.1.1/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/superset/stackable/patches/3.0.1/001-26885-query-export-fix.patch b/superset/stackable/patches/3.0.1/001-26885-query-export-fix.patch new file mode 100644 index 000000000..765cb98d5 --- /dev/null +++ b/superset/stackable/patches/3.0.1/001-26885-query-export-fix.patch @@ -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, diff --git a/superset/stackable/patches/apply_patches.sh b/superset/stackable/patches/apply_patches.sh new file mode 100755 index 000000000..5d5b39ff3 --- /dev/null +++ b/superset/stackable/patches/apply_patches.sh @@ -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."