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

   ### SUMMARY
   Enable Jinja-aware SQL formatting by passing database_id/template_params 
from the UI and processing templates server-side before formatting.
   This is used on the experimental **Parameters** feature of the SQL Labs.
   
   #### Details
   - **Backend**:
     - `POST /api/v1/sqllab/format_sql/` now accepts `database_id` and 
`template_params` (JSON string) via `FormatQueryPayloadSchema`.
     - Processes Jinja templates (via `get_template_processor`) before running 
`SQLScript.format`.
    
   - **Frontend (SQL Lab)**:
     - `formatQuery` includes `database_id` and `template_params` (stringified 
when needed) from the up-to-date query editor state in the request body.
   
   - **Tests**:
     - Add unit tests for `formatQuery` payload construction and dispatch 
behavior.
     - Add integration test verifying Jinja template resolution in `format_sql` 
response.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   #### Before
   
   
https://github.com/user-attachments/assets/e9ca8146-a300-4cb3-8419-d7f5d0470dee
   
   #### After
   
   
https://github.com/user-attachments/assets/52866da2-79ca-4cb0-92f1-3749546f2ee1
   
   ### TESTING INSTRUCTIONS
   
   1. Navigate to SQL Lab.
   2. Make sure the `examples` DB is selected.
   3. Click on the three ellipses on the bottom right > Parameters.
   4. Set `{"tbl": "\"Vehicle Sales\""}` as the parameter value.
   5. Run `select * from {{tbl}} `and validate the query works.
   6. Click on the three ellipses on the bottom right > Format SQL.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [x] Has associated issue:
   - [ ] Required feature flags: `ENABLE_TEMPLATE_PROCESSING`
   - [ ] 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


-- 
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