MCPcopy Index your code
hub / github.com/cockroachdb/cockroachdb-parser

github.com/cockroachdb/cockroachdb-parser @v0.25.2.5.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.25.2.5.0 ↗ · + Follow
11,786 symbols 28,081 edges 624 files 7,710 documented · 65% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

cockroachdb-parser

Go Reference Tests

cockroachdb-parser is a snapshot of the parser package and all its dependencies from the CockroachDB 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.

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 is cloned in your $GOPATH, and then type:

./snapshot.sh

Extension points exported contracts — how you extend this code

ResolvableTypeReference (Interface)
ResolvableTypeReference represents a type that is possibly unknown until type-checking/type name resolution is performed [7 …
pkg/sql/sem/tree/type_name.go
Shape (Interface)
Shape is an interface that represents any Geospatial shape. [7 implementers]
pkg/geo/geodist/geodist.go
Message (Interface)
Message extends the proto.Message interface with the MarshalTo and Size methods we tell gogoproto to generate for us. [50 …
pkg/util/protoutil/marshal.go
Column (Interface)
Column is an interface that represents a raw array of a Go native type. [19 implementers]
pkg/col/coldata/vec.go
Updater (Interface)
Updater is a helper for updating the in-memory settings. RefreshSettings passes the serialized representations of all i [2 …
pkg/settings/updater.go
Datum (Interface)
Datum represents a SQL value. [27 implementers]
pkg/sql/sem/tree/datum.go
DistanceUpdater (Interface)
DistanceUpdater is a provided hook that has a series of functions that allows the caller to maintain the distance value [3 …
pkg/geo/geodist/geodist.go
Doc (Interface)
Doc represents a document as described by the type "DOC" in the referenced paper. This is the abstract representation co [11 …
pkg/util/pretty/document.go

Core symbols most depended-on inside this repo

FormatNode
called by 800
pkg/sql/sem/tree/format.go
Errorf
called by 730
pkg/col/coldata/testutils.go
Newf
called by 354
pkg/sql/pgwire/pgerror/errors.go
AsString
called by 328
pkg/sql/sem/tree/format.go
MakeCode
called by 270
pkg/sql/pgwire/pgcode/codes.go
String
called by 209
pkg/sql/sem/tree/overload.go
Doc
called by 208
pkg/sql/sem/tree/pretty.go
Family
called by 187
pkg/sql/types/types.go

Shape

Method 7,265
Function 2,789
Struct 1,188
TypeAlias 345
Interface 162
FuncType 23
Class 11
Enum 3

Languages

Go99%
C++1%
C1%

Modules by API surface

pkg/sql/sem/tree/stmt.go945 symbols
pkg/sql/sem/tree/datum.go664 symbols
pkg/util/json/json.go340 symbols
pkg/sql/sem/tree/eval_op_generated.go305 symbols
pkg/sql/sem/tree/expr.go257 symbols
pkg/util/encoding/encoding.go219 symbols
pkg/sql/sem/tree/walk.go186 symbols
pkg/sql/sem/tree/create.go174 symbols
pkg/sql/sem/plpgsqltree/statements.go168 symbols
pkg/sql/sem/tree/pretty.go151 symbols
pkg/sql/sem/tree/type_check.go150 symbols
pkg/sql/sem/tree/show.go144 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add cockroachdb-parser \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact