dosubot[bot] commented on issue #38339: URL: https://github.com/apache/superset/issues/38339#issuecomment-3983404082
<!-- Greeting --> Hi @MallikarjunaReddyN! I'm [Dosu](https://go.dosu.dev/dosubot) and Iām helping the superset team. <!-- Answer --> This is a known issue caused by a mismatch between column labels and physical column names in Superset's query building system. **Root Cause:** In [`get_sqla_query`](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/models/helpers.py#L1769), the [`columns_by_name` dictionary is keyed by physical column names](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/models/helpers.py#L1511), not display labels. When the search filter references "Id" (the label), `columns_by_name.get("Id")` returns `None` because the key is "CustomerID", causing the filter to be [rejected with `COL_NOT_IN_DATASOURCE`](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/models/helpers.py#L2089). **Related Issues:** - [#37520](https://github.com/apache/superset/issues/37520) - Same issue affects ORDER BY with custom SQL expression columns - [PR #37521](https://github.com/apache/superset/pull/37521) - Fixed the ORDER BY version of this bug by checking if references match adhoc column labels and properly resolving them **Potential Fix:** The search filter handling needs similar logic to PR #37521 ā check if the filter column matches an adhoc/renamed column's label, then resolve it to the actual column reference before applying the filter. <!-- 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/cf24264a-cacf-4834-b8bd-30a1d98c4de7?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/cf24264a-cacf-4834-b8bd-30a1d98c4de7?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/cf24264a-cacf-4834-b8bd-30a1d98c4de7?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/cf24264a-cacf-4834-b8bd-30a1d98c4de7?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cf24264a-cacf-4834-b8bd-30a1d98c4de7?feedback_type=hallucination) | [Report š](https://app.dosu.dev/response-feedback/cf24264a-cacf-4834-b8bd-30a1d98c4de7?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/cf24264a-cacf-4834-b8bd-30a1d98c4de7?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=This%20is%20a%20known%20issue%20caused%20by%20a%20mismatch%20between%20column%20labels%20and%20physical%20column%20names%20in%20Superset%27s%20query%20building%20system.%0A%0A%2A%2ARoot%20Cause%3A%2A%2A%20In%20%5B%60get_sqla_query%60%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/models/helpers.py%23L1769%29%2C%20the%20%5B%60columns_by_name%60%20dictionary%20is%20keyed%20by%20physical%20column%20names%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/models/helpers.py%23L1511%29%2C%20not%20display%20labels.%20When%20the%20search%20filter%20references%20%22Id%22%20%28the%20label%29%2C%20%60columns_by_name.get%28%22Id%22%29%60%20returns%20%60None%60%20bec ause%20the%20key%20is%20%22CustomerID%22%2C%20causing%20the%20filter%20to%20be%20%5Brejected%20with%20%60COL_NOT_IN_DATASOURCE%60%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/models/helpers.py%23L2089%29.%0A%0A%2A%2ARelated%20Issues%3A%2A%2A%0A-%20%5B%2337520%5D%28https%3A//github.com/apache/superset/issues/37520%29%20-%20Same%20issue%20affects%20ORDER%20BY%20with%20custom%20SQL%20expression%20columns%0A-%20%5BPR%20%2337521%5D%28https%3A//github.com/apache/superset/pull/37521%29%20-%20Fixed%20the%20ORDER%20BY%20version%20of%20this%20bug%20by%20checking%20if%20references%20match%20adhoc%20column%20labels%20and%20properly%20resolving%20them%0A%0A%2A%2APotential%20Fix%3A%2A%2A%20The%20search%20filter%20handling%20needs%20similar%20logic%20to%20PR%20%2337521%20%E2%80%94%20check%20if%20the%20filter%20column%20matches%20an%20adhoc/renamed%20column%27s%20label%2C%20then%20resolve%20it%20to%20the%20actual%20column%20reference%20before%20ap plying%20the%20filter.) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/38339) -- 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]
