Skip to content

UNION ALL in CTE rises a read only error #25266

@nicolaspi

Description

@nicolaspi

When using sqloxide, the logic for testing if a CTE is a select statement doesn't account for set operations.

How to reproduce the bug

SQLLab: WITH t AS ( SELECT 1 UNION ALL SELECT 2 ) SELECT * FROM t

Python interpreter:

import superset.sql_parse as sql_parse
assert sql_parse.sqloxide_parse is not None, "The case only fails when sqloxide is used"

parsed_query = sql_parse.ParsedQuery("""WITH t AS (
SELECT 1 UNION ALL SELECT 2
)
SELECT * FROM t""")

print("Is select:", parsed_query.is_select())

Expected results

Interpreter: Is select: True

Actual results

SQLLAb: Only SELECT statements are allowed against this database.
Interpreter: Is select: False

Environment

The problem arises only when sqloxide is installed.

Checklist

Make sure to follow these steps 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.

Additional context

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions