代码拉取完成,页面将自动刷新
PostgreSQL style Parser splitted from CockroachDB
See: Complex SQL format example
I tried to import github.com/cockroachdb/cockroach/pkg/sql/parser
, but the dependencies is too complex to make it work.
To make things easy, I did these things:
pkg/sql/parser
, pkg/sql/lex
and simplify the dependenciesgo get
work easily, see the .gitignore
filesetcd
dependency, see the go.mod
pkg/sql/parser
testspanic
of meeting unregistried functions, see the WrapFunctioncockroachdb
style PostgreSQL)The code is derived from CockroachDB v20.1.11 which supports most of the major features of SQL:2011. See:
package main
import (
"log"
"gitee.com/shiqiyue/postgresql-parser/pkg/walk"
)
func main() {
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(ctx interface{}, node interface{}) (stop bool) {
log.Printf("node type %T", node)
return false
},
}
_, _ = w.Walk(sql, nil)
return
}
gitee.com/shiqiyue/postgresql-parser/pkg/sql/parser
Unit tests works now!此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。