dosubot[bot] commented on issue #25839:
URL: https://github.com/apache/superset/issues/25839#issuecomment-3643862476

   <!-- Answer -->
   The sync columns logic lives mainly in the backend in the `SqlaTable` class, 
specifically the `fetch_metadata` method in 
[`superset/connectors/sqla/models.py`](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/connectors/sqla/models.py#L818-L1867).
 This method fetches and merges column metadata from the database, but does not 
process or strip Jinja templating syntax before running the sync, which is why 
SQL errors occur when template variables are present in the dataset SQL.
   
   On the frontend, the sync is triggered by the `syncMetadata` method in the 
`DatasourceEditor` component 
(`superset-frontend/src/components/Datasource/DatasourceEditor.jsx`), which 
calls `fetchSyncedColumns` and updates columns in state. Recent PRs have 
improved the UI and added options to skip syncing, but none address Jinja 
handling during sync columns—so the issue still exists in Superset 5.0+ as of 
the latest code and merged PRs 
[1](https://github.com/apache/superset/pull/30903), 
[2](https://github.com/apache/superset/pull/35650).
   
   For anyone wanting to contribute a fix: the backend `fetch_metadata` method 
is the key place to add logic to temporarily strip or safely process Jinja 
syntax before syncing columns. The frontend logic is in `DatasourceEditor` and 
`DatasourceModal`, but the core issue is backend-side.
   
   Let me know if you want a diagram of the sync flow or more details on 
specific files/methods!
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/6cda8463-2a2d-4e31-a497-536f065f154a?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/6cda8463-2a2d-4e31-a497-536f065f154a?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/6cda8463-2a2d-4e31-a497-536f065f154a?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/6cda8463-2a2d-4e31-a497-536f065f154a?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/6cda8463-2a2d-4e31-a497-536f065f154a?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/6cda8463-2a2d-4e31-a497-536f065f154a?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/6cda8463-2a2d-4e31-a497-536f065f154a?feedback_type=other)</sup>
   
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20sync%20columns%20logic%20lives%20mainly%20in%20the%20backend%20in%20the%20%60SqlaTable%60%20class%2C%20specifically%20the%20%60fetch_metadata%60%20method%20in%20%5B%60superset/connectors/sqla/models.py%60%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/connectors/sqla/models.py%23L818-L1867%29.%20This%20method%20fetches%20and%20merges%20column%20metadata%20from%20the%20database%2C%20but%20does%20not%20process%20or%20strip%20Jinja%20templating%20syntax%20before%20running%20the%20sync%2C%20which%20is%20why%20SQL%20errors%20occur%20when%20template%20variables%20are%20present%20in%20the%20dataset%20SQL.%0A%0AOn%20the%20frontend%2C%20the%20sync%20is%20triggered%20by%20the%20%60syncMetadata%60%20meth
 
od%20in%20the%20%60DatasourceEditor%60%20component%20%28%60superset-frontend/src/components/Datasource/DatasourceEditor.jsx%60%29%2C%20which%20calls%20%60fetchSyncedColumns%60%20and%20updates%20columns%20in%20state.%20Recent%20PRs%20have%20improved%20the%20UI%20and%20added%20options%20to%20skip%20syncing%2C%20but%20none%20address%20Jinja%20handling%20during%20sync%20columns%E2%80%94so%20the%20issue%20still%20exists%20in%20Superset%205.0%2B%20as%20of%20the%20latest%20code%20and%20merged%20PRs%20%5B1%5D%28https%3A//github.com/apache/superset/pull/30903%29%2C%20%5B2%5D%28https%3A//github.com/apache/superset/pull/35650%29.%0A%0AFor%20anyone%20wanting%20to%20contribute%20a%20fix%3A%20the%20backend%20%60fetch_metadata%60%20method%20is%20the%20key%20place%20to%20add%20logic%20to%20temporarily%20strip%20or%20safely%20process%20Jinja%20syntax%20before%20syncing%20columns.%20The%20frontend%20logic%20is%20in%20%60DatasourceEditor%60%20and%20%60DatasourceModal%60%2C%20but%20the%20core%20issue%2
 
0is%20backend-side.%0A%0ALet%20me%20know%20if%20you%20want%20a%20diagram%20of%20the%20sync%20flow%20or%20more%20details%20on%20specific%20files/methods%21)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/25839)


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