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

   ### SUMMARY
   
   In the Explore view, SQL expression autocomplete suggestions do not appear 
when creating custom dimensions or filters using the "Custom SQL" tab. However, 
the same feature works correctly for custom metrics.
   
   ### Root Cause
   During the migration from `SQLEditor` to `SQLEditorWithValidation` in this 
[PR,](https://github.com/apache/superset/pull/34642) keywords were transformed 
before being passed to the SQL editor:
   
   ```typescript
   keywords={keywords.map((k: any) =>
     typeof k === 'string' ? k : k.value || k.name || k,
   )}
   ```
   
   This transformation simplified keyword objects into plain strings, which 
removed the metadata (like `docHTML`, `score`, `meta`) that Ace Editor uses for 
rich autocomplete suggestions.
   
   **Affected files:**
   - `ColumnSelectPopover.tsx` (dimensions)
   - `AdhocFilterEditPopoverSqlTabContent/index.tsx` (filters)
   
   ### Solution
   Remove the `.map()` transformation and pass keywords directly:
   
   ```typescript
   keywords={keywords}
   ```
   
   This aligns with how the metrics component handles keywords and preserves 
the full keyword object structure that Ace Editor needs for autocomplete.
   
   ### Alternatives Considered
   
   1. **Modify the transformation to preserve object structure** - Would work, 
but adds unnecessary complexity since the transformation isn't needed.
   
   2. **Add runtime validation at the `SQLEditorWithValidation` level** - Could 
ensure keywords are objects, but better to address at the source.
   
   3. **Create a shared utility for keyword handling** - Could centralize 
keyword preparation across all popovers, but this is beyond the scope of this 
fix.
   
   **Chosen approach:** Removing the transformation is the simplest fix and 
matches the working metrics implementation.
   
   ### Regression Prevention
   Added a component-level test in `ColumnSelectPopover.test.tsx` that:
   - Mocks `SQLEditorWithValidation` to capture the props it receives
   - Verifies keywords are passed as objects with required properties
   - Checks that column keywords include `docHTML` for rich tooltips
   
   ### Testing
   1. **Dimensions**: Open Explore → Add dimension → Custom SQL tab → Type 
column name → Verify suggestions appear with column names, types, and 
descriptions
   2. **Filters**: Open Explore → Add filter → Custom SQL tab → Type column 
name → Verify suggestions appear
   3. **Metrics**: Verify still works (regression check)
   
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   #### BEFORE
   
   
https://github.com/user-attachments/assets/67e5aae3-4d48-474c-bee7-8883ba63b8b3
   
   #### AFTER
   
   
https://github.com/user-attachments/assets/31720e40-5fb2-47d7-9c53-dd3e2d1f64bd
   
   
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] 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
   


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