eschutho opened a new pull request, #35540:
URL: https://github.com/apache/superset/pull/35540

   ### SUMMARY
   Refactors the `select_star` method across all database engine specs to use 
`dialect: Dialect` instead of `engine: Engine` as a parameter. This 
optimization prevents unnecessary SSH tunnel connections from being created 
when only the database dialect is needed for SQL generation.
   
   **Problem**: The previous implementation used `get_sqla_engine()` which 
establishes a full database connection (including SSH tunnels when configured), 
but the `select_star` method only needs the dialect to generate SQL statements.
   
   **Solution**: 
   - Changed `select_star` method signature from `engine: Engine` to `dialect: 
Dialect` in `BaseEngineSpec` and all subclasses (BigQuery, Hive, Presto)
   - Updated `Database.select_star()` to call lightweight `get_dialect()` 
instead of `get_sqla_engine()`
   - Removed unused `Engine` imports from Hive and Presto engine specs
   - Updated all related unit tests to pass `dialect` instead of `engine`
   
   **Impact**: This reduces unnecessary connection overhead, particularly for 
databases configured with SSH tunnels, improving performance when generating 
SELECT statements for table previews.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A - Backend refactoring only, no UI changes
   
   ### TESTING INSTRUCTIONS
   1. Run the updated unit tests:
      ```bash
      pytest tests/unit_tests/db_engine_specs/ -k select_star -v
      ```
      All 5 tests should pass (base, bigquery, hive, postgres, presto)
   
   2. Verify type checking passes:
      ```bash
      pre-commit run mypy
      ```
   
   3. (Optional) Test with a database configured with SSH tunnel:
      - Configure a database connection with SSH tunnel
      - View a table in SQL Lab
      - Verify table preview loads correctly without creating extra SSH 
connections
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-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]

Reply via email to