rusackas opened a new pull request, #37311: URL: https://github.com/apache/superset/pull/37311
### SUMMARY When importing example datasets, this PR automatically transpiles virtual dataset SQL to the target database dialect using SQLGlot. This ensures that virtual datasets exported from one database type (e.g., PostgreSQL) can be loaded into a different database type (e.g., MySQL, DuckDB, SQLite). **Problem:** Virtual datasets contain raw SQL that is dialect-specific. If someone exports a dashboard with virtual datasets from PostgreSQL (using syntax like `DATE_TRUNC`, `::` casting, etc.) and someone else tries to load it with MySQL or SQLite, the SQL would fail. **Solution:** Leverage Superset's existing `transpile_to_dialect()` function (which uses SQLGlot) to automatically convert the SQL to the target database's dialect during import. **Changes:** - Add `transpile_virtual_dataset_sql()` helper function in `superset/commands/importers/v1/examples.py` - Integrate transpilation into `ImportExamplesCommand._import()` before dataset import - Gracefully fall back to original SQL if transpilation fails (logs a warning) - Add 7 comprehensive unit tests This builds on the work from #36538 which modernized example data loading with Parquet and YAML configs. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A - Backend change only ### TESTING INSTRUCTIONS 1. Export a dashboard with virtual datasets from a PostgreSQL-backed Superset instance 2. Configure a different database engine (e.g., DuckDB, MySQL) as the examples database 3. Run `superset load-examples` 4. Verify that virtual datasets are created with SQL transpiled to the target dialect **Unit tests:** ```bash pytest tests/unit_tests/commands/importers/v1/examples_test.py -v ``` ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration - [x] Introduces new feature or API - [ ] Removes existing feature or API 🤖 Generated with [Claude Code](https://claude.ai/code) -- 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]
