You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"log""github.com/auxten/postgresql-parser/pkg/sql/parser""github.com/auxten/postgresql-parser/pkg/walk"
)
funcmain() {
sql:=`select marr from (select marr_stat_cd AS marr, label AS l from root_loan_mock_v4 order by root_loan_mock_v4.age desc, l desc limit 5) as v4 LIMIT 1;`w:=&walk.AstWalker{
Fn: func(ctxinterface{}, nodeinterface{}) (stopbool) {
log.Printf("node type %T", node)
returnfalse
},
}
stmts, err:=parser.Parse(sql)
iferr!=nil {
return
}
_, _=w.Walk(stmts, nil)
return
}
SQL parser
This project contains code that is automatically generated using goyacc.
goyacc reads the SQL expressions (sql.y) and generates a parser which could be used to tokenize a given input.
You could update the generated code using the generate target inside the project's Makefile.
$ make generate
Progress
2021-02-16 github.com/auxten/postgresql-parser/pkg/sql/parser Unit tests works now!
2021-03-08 Add walker package.
2022-08-03 Remove vendored dependencies by @mostafa in #19
Todo
Fix more unit tests
Make built-in function parsing work
About
Pure Golang PostgreSQL (SQL:2011, SQL:2008, SQL:2003, SQL:1999, and SQL-92 Standard) Parser