superset: Superset chart incorrectly throwing error Virtual dataset query must be read-only
A chart built off of a virtual datasource is erroring saying that the virtual datasource must be readonly but the query is only a select query (it is not modifying any table). It does contain WITH statements, and removing the WITH statements doesn’t result in the error. It seems like queries with WITH statements are getting miscategorized as “Readonly”.
Result:
Error thrown: Virtual dataset query must be read-only
Expected Result: Chart should load
Looks like regression caused by https://github.com/apache/incubator-superset/pull/11236#issuecomment-710669738
Environment
(please complete the following information):
- superset version: master
Checklist
Make sure these boxes are checked before submitting your issue - thank you!
- I have checked the superset logs for python stacktraces and included it here as text if there are any.
- I have reproduced the issue with at least the latest released version of superset.
- I have checked the issue tracker for the same issue and I haven’t found one similar.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 18 (10 by maintainers)
We have just upgraded to 3.1.2 and facing same error wherever we have UNION or UNION ALL inside CTE . Is there any solution we have? Please share. This Issue I have faced with Redshift and Postgresql both.
For ref I have attached Error Query and working query.
problematic query:
At same Time when I removed UNION ALL statement and make separate CTE and then apply union , this worked well.
working query:
Well, I was exploring the error and discovered that (in my case) it occurred because the queries to build the virtual datasets had the
UNIONorUNION ALLstatements, and when they were validated in sql_parse they generated the error.This bug was fixed in #25290 by @betodealmeida. Therefore, the solution I applied was to upgrade to version 3.0.1.
@zhaoyongjie I tested on apache master. This problem specifically occurs when there is no space between
ASand the select statement. i.e.WITH test AS(select country, ....Thanks @JersonFerrer for the update! Can anyone else test with 3.0.1 and verify that it addressed their problem? I could then close the issue.
Facing the same issue in the version 3.0.0. I recently upgraded to 3.0.0-dev image from the 2.1.1-dev image and few of the charts which are using the WITH keyword are failing to load with an error of
Virtual dataset query must be read-only.Requesting to open this issue again.
For reference, I think this is where the lack of magic happens: https://github.com/andialbrecht/sqlparse/blob/master/sqlparse/sql.py#L425-L436
+1 getting the same error