apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
62.91k stars 13.91k forks source link

fix(dataset): use sqlglot for DML check #31024

Closed betodealmeida closed 3 hours ago

betodealmeida commented 17 hours ago

SUMMARY

Use sqlglot when getting column metadata for a virtual dataset. We currently use sqlglot to check for DML in SQL Lab, but when we save a query as a dataset we're still using sqlparse.

Part of SIP-117.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A

TESTING INSTRUCTIONS

Run this query in SQL Lab:

with source as ( select 1 as one ) select * from source

This query is flagged incorrectly as DML by sqlparse, but not by sqlglot.

After running, save the query as a dataset. It should work, but currently it fails because sqlparse flags the query as having DML.

ADDITIONAL INFORMATION