pingcap / parser

A MySQL Compatible SQL Parser
Apache License 2.0
1.41k stars 489 forks source link

how can use "with xx select" syntax #1331

Closed ftlynx closed 3 years ago

ftlynx commented 3 years ago

Question

func Parse(sql string) (*ast.StmtNode, error) { p := parser.New() stmtNode, err := p.ParseOneStmt(sql, "", "") if err != nil { return nil, err } return &stmtNode, nil }

sql: with tmp_table as (select * from t1) select * from tmp_table result: syntax error

kennytm commented 3 years ago

hi. which version of pingcap/parser are you using?

ftlynx commented 3 years ago

version: v4.0.2

MacBook-Pro:~ ftlynx$ cat go.mod | grep ping github.com/pingcap/parser v0.0.0-20200623164729-3a18f1e5dceb github.com/pingcap/tidb v1.1.0-beta.0.20200630082100-328b6d0a955c

kennytm commented 3 years ago

CTE parser was implemented in #1207 & #1217, you'll need a parser version of at least 20210429.

ftlynx commented 3 years ago

thanks