dosubot[bot] commented on issue #36954: URL: https://github.com/apache/superset/issues/36954#issuecomment-3800991091
<!-- Answer --> The root cause is that Superset's SQL parser (sqlglot) doesn't recognize the `RETURNING` clause in the `json_value` function, so it throws a parse error before the query reaches Druid or PostgreSQL. This limitation appeared after Superset switched to sqlglot for SQL parsing, and similar issues have been reported for other dialect-specific SQL extensions and JSON function clauses (like Trino's `OMIT QUOTES` or TimescaleDB hyperfunctions) [example](https://github.com/apache/superset/issues/32028) [example](https://github.com/apache/superset/issues/31768). Current workarounds are: use an explicit `CAST` instead of the `RETURNING` clause, run queries in SQLLab (where parsing is less strict), or ask your DBAs to create a view that avoids the problematic syntax [example](https://github.com/apache/superset/discussions/33436). A long-term fix would require sqlglot to add support for this syntax. If you want this resolved natively, you may want to track or upvote a feature request in the sqlglot repository. <!-- 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/6befaa3c-df3f-4657-9009-8ca2bf0cbcca?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/6befaa3c-df3f-4657-9009-8ca2bf0cbcca?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/6befaa3c-df3f-4657-9009-8ca2bf0cbcca?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/6befaa3c-df3f-4657-9009-8ca2bf0cbcca?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6befaa3c-df3f-4657-9009-8ca2bf0cbcca?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/6befaa3c-df3f-4657-9009-8ca2bf0cbcca?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/6befaa3c-df3f-4657-9009-8ca2bf0cbcca?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=The%20root%20cause%20is%20that%20Superset%27s%20SQL%20parser%20%28sqlglot%29%20doesn%27t%20recognize%20the%20%60RETURNING%60%20clause%20in%20the%20%60json_value%60%20function%2C%20so%20it%20throws%20a%20parse%20error%20before%20the%20query%20reaches%20Druid%20or%20PostgreSQL.%20This%20limitation%20appeared%20after%20Superset%20switched%20to%20sqlglot%20for%20SQL%20parsing%2C%20and%20similar%20issues%20have%20been%20reported%20for%20other%20dialect-specific%20SQL%20extensions%20and%20JSON%20function%20clauses%20%28like%20Trino%27s%20%60OMIT%20QUOTES%60%20or%20TimescaleDB%20hyperfunctions%29%20%5Bexample%5D%28https%3A//github.com/apache/superset/issues/32028%29%20%5Bexample%5D%28https%3A//github.com/apache/superset/issues/31768%29.%0A%0ACurrent%20wor karounds%20are%3A%20use%20an%20explicit%20%60CAST%60%20instead%20of%20the%20%60RETURNING%60%20clause%2C%20run%20queries%20in%20SQLLab%20%28where%20parsing%20is%20less%20strict%29%2C%20or%20ask%20your%20DBAs%20to%20create%20a%20view%20that%20avoids%20the%20problematic%20syntax%20%5Bexample%5D%28https%3A//github.com/apache/superset/discussions/33436%29.%0A%0AA%20long-term%20fix%20would%20require%20sqlglot%20to%20add%20support%20for%20this%20syntax.%20If%20you%20want%20this%20resolved%20natively%2C%20you%20may%20want%20to%20track%20or%20upvote%20a%20feature%20request%20in%20the%20sqlglot%20repository.) [](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/36954) -- 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]
