https://github.com/cockroachdb/cockroachdb-parser
Apache licensed CockroachDB parser and dependencies.
https://github.com/cockroachdb/cockroachdb-parser
Last synced: 9 days ago
JSON representation
Apache licensed CockroachDB parser and dependencies.
- Host: GitHub
- URL: https://github.com/cockroachdb/cockroachdb-parser
- Owner: cockroachdb
- License: apache-2.0
- Created: 2022-06-06T00:50:55.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-13T11:24:35.000Z (13 days ago)
- Last Synced: 2025-06-13T14:02:30.753Z (13 days ago)
- Language: Go
- Homepage:
- Size: 3.36 MB
- Stars: 37
- Watchers: 46
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cockroachdb-parser
[](https://pkg.go.dev/github.com/cockroachdb/cockroachdb-parser)
[](https://github.com/cockroachdb/cockroachdb-parser/actions/workflows/go.yml)`cockroachdb-parser` is a snapshot of the parser package and
all its dependencies from the [CockroachDB repo][repo]. The
smaller package is Apache licensed and contains less dependencies
to pull in when configuring compared to `go get github.com/cockroachdb/cockroach`.A README of usage of the parser library can be found [here][parserreadme].
The SHA this is based off is available in `version`.
## Versioning
Versioning is done by CockroachDB version, with a `v0.` prepended.
For example, `v0.22.1.0.x.y` maps to `v22.1.0` in CockroachDB, where
`.x.y` maps to any subiterations.## Custom patches
There are custom patches in `patches/` which gets applied to the repo.
This helps us customise the parser slightly for third party users.## Example usage
```
import (
...
"github.com/cockroachdb/cockroachdb-parser/pkg/sql/parser"
...
)func Parse() error {
ast, err := parser.ParseOne("SELECT 1")
if err != nil {
return err
}
// Do something with the AST
_ = ast
}
```## Generating a snapshot
Ensure the [CockroachDB repo][repo] is cloned in your $GOPATH, and then type:
```sh
./snapshot.sh
```[repo]: https://github.com/cockroachdb/cockroach
[parserreadme]: pkg/sql/parser/README.md