This does not work for me with version 0.1.18:
>>> import sqlparse
>>> sql = """ create procedure db.sp()
... begin
...
... create table t1 select a from t where abc;
...
... create table t2 select
... avg(a) as a,
... std(a) as a,
... avg(a) as a,
... std(a) as a,
... avg(a) as a,
... std(a) as a,
... avg(a) as a,
... std(a) as a,
... avg(a) as a,
... std(a) as a,
... avg(a) as a,
... std(a) as a
... from t ;
...
... create table t3
... select
... a,
... 0
... from t;
...
... end;
... """
>>> sqlparse.parse(sql)
This fixes it:
>>> sqlparse.parse(sql.replace('end; \n', 'end'))
and so does messing round with the sql statements (e.g. deleting one of the columns in t2 or t3). I've had a quick look, and while I don't know the root of the cause, it might pay to add an if tokens: ... into group_tokens in sql.py.
This does not work for me with version 0.1.18:
This fixes it:
and so does messing round with the sql statements (e.g. deleting one of the columns in
t2ort3). I've had a quick look, and while I don't know the root of the cause, it might pay to add anif tokens: ...intogroup_tokensinsql.py.