Milad93R opened a new pull request, #37120:
URL: https://github.com/apache/superset/pull/37120
## Summary
This PR fixes issue #37113 where exporting dashboards containing charts from
different databases would result in missing charts and their corresponding
database YAML files in the exported ZIP.
## Problem
When a dashboard contains charts from multiple databases, the export command
fails to include all charts and database files. This happens because:
1. Each export command (`ExportDashboardsCommand`, `ExportChartsCommand`,
`ExportDatasetsCommand`) maintains its own isolated `seen` set for deduplication
2. When nested commands are called via `yield from command.run()`, they
create new `seen` sets
3. Files that should be included get incorrectly filtered out because the
deduplication happens at the wrong level
## Solution
Implemented a shared deduplication context that is passed through the entire
export hierarchy:
1. Modified `ExportModelsCommand.run()` to accept an optional `seen`
parameter
2. Updated all export commands to pass the shared `seen` set to nested
commands
3. Each command now adds to the shared set instead of creating isolated ones
4. Database files are only yielded if not already in the shared `seen` set
## Changes
### Core Changes
- `superset/commands/export/models.py`: Base command now supports shared
deduplication
- `superset/commands/dashboard/export.py`: Passes shared context to nested
exports
- `superset/commands/chart/export.py`: Uses shared context for dataset
exports
- `superset/commands/dataset/export.py`: Critical fix - only exports
database if not seen
- `superset/commands/database/export.py`: Supports shared context
- `superset/commands/theme/export.py`: Updated for consistency
- `superset/commands/query/export.py`: Prevents duplicate database exports
### Testing
- Added `test_export_dashboard_cross_database_charts` test case that:
- Creates a dashboard with charts from multiple databases
- Verifies all charts and databases are exported correctly
- Ensures no duplicates or missing files
## Backward Compatibility
- All changes are backward compatible
- If no `seen` set is provided, commands create their own (existing behavior)
- No breaking changes to public APIs
## Testing Instructions
1. Create a dashboard with charts from database A
2. Add new charts from database B to the same dashboard
3. Export the dashboard
4. Verify the ZIP contains:
- All charts from both databases
- Both database YAML files
- All related datasets
## Related Issue
Fixes #37113
## Pre-submission Checklist
- [x] The code follows Apache Superset's coding standards
- [x] Tests have been added to verify the fix
- [x] All syntax checks pass
- [x] The change is backward compatible
- [x] Related documentation has been reviewed
## Notes
This fix ensures that dashboard exports are complete and reliable,
especially in environments where dashboards aggregate data from multiple
sources. The shared deduplication context prevents file loss while maintaining
proper deduplication.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]