sqlparser icon indicating copy to clipboard operation
sqlparser copied to clipboard

Support With Clause

Open tlightsky opened this issue 7 years ago • 3 comments

https://dev.mysql.com/doc/refman/8.0/en/with.html#common-table-expressions-syntax

tlightsky avatar Apr 14 '19 16:04 tlightsky

Hi, could I check if there are any recent plans for WITH statements to be supported?

quattad avatar Nov 08 '23 10:11 quattad

I think an alternative workaround here is to use the parser in the Vitess project directly. Since PR https://github.com/vitessio/vitess/pull/8918 it "Add parsing for common table expressions using WITH clause"

I think the SQL Parser can be imported with import "vitess.io/vitess/go/vt/sqlparser" - but I think the API is different - it doesn't seem to have a sqlparser.Parse('[string of SQL]') method any more.

EDIT I got this working. You can see how I used it here: https://github.com/grafana/grafana/pull/96296/commits/3d952d074e541cf496a06241e8de0fe35b5757ec

It works fine on CTEs 🎉

samjewell avatar Nov 12 '24 12:11 samjewell

There's a second alternative workaround too - use DoltHub's hard-fork of the Vitess project, which is this one: github.com/dolthub/[email protected]

I got this working too, here: https://github.com/grafana/grafana/pull/96296/commits/45f9adf845baa030e74cc14e18d12b9453bd17d3

samjewell avatar Nov 13 '24 16:11 samjewell