GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - sqlc-dev/doubleclick

BranchesTags
Open more actions menu

Latest commit

 

History

117 Commits
117 Commits

Folders and files

NameName
Last commit message
Last commit date
.claude
.claude
 
 
.github
.github
 
 
ast
ast
 
 
cmd
cmd
 
 
internal/explain
internal/explain
 
 
lexer
lexer
 
 
parser
parser
 
 
token
token
 
 
.gitignore
.gitignore
 
 
CLAUDE.md
CLAUDE.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 

Repository files navigation

doubleclick

Go Reference

A ClickHouse SQL parser written in Go. Parses ClickHouse SQL syntax into an Abstract Syntax Tree (AST) and generates EXPLAIN output matching ClickHouse's format.

Installation

go get github.com/sqlc-dev/doubleclick

Usage

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"strings"

	"github.com/sqlc-dev/doubleclick/parser"
)

func main() {
	sql := `SELECT id, name FROM users WHERE active = 1 ORDER BY created_at DESC LIMIT 10`

	stmts, err := parser.Parse(context.Background(), strings.NewReader(sql))
	if err != nil {
		panic(err)
	}

	// Serialize to JSON
	jsonBytes, _ := json.MarshalIndent(stmts[0], "", "  ")
	fmt.Println(string(jsonBytes))

	// Or print EXPLAIN AST output (matches ClickHouse format)
	fmt.Println(parser.Explain(stmts[0]))
}

JSON output:

{
  "selects": [
    {
      "columns": [
        { "parts": ["id"] },
        { "parts": ["name"] }
      ],
      "from": {
        "tables": [
          { "table": { "table": { "table": "users" } } }
        ]
      },
      "where": {
        "left": { "parts": ["active"] },
        "op": "=",
        "right": { "type": "Integer", "value": 1 }
      },
      "order_by": [
        {
          "expression": { "parts": ["created_at"] },
          "descending": true
        }
      ],
      "limit": { "type": "Integer", "value": 10 }
    }
  ]
}

EXPLAIN output:

SelectWithUnionQuery (children 1)
 ExpressionList (children 1)
  SelectQuery (children 4)
   ExpressionList (children 2)
    Identifier id
    Identifier name
   TablesInSelectQuery (children 1)
    TablesInSelectQueryElement (children 1)
     TableExpression (children 1)
      TableIdentifier (children 1)
       Identifier users
   Function equals (children 1)
    ExpressionList (children 2)
     Identifier active
     Literal UInt64_1
   ExpressionList (children 1)
    OrderByElement (children 1)
     Identifier created_at
   Literal UInt64_10

Features

  • Parses SELECT, INSERT, CREATE, DROP, ALTER, and other ClickHouse statements
  • Handles ClickHouse-specific syntax (Array types, PREWHERE, SAMPLE, etc.)
  • Supports JOINs, subqueries, CTEs, window functions, and complex expressions
  • Generates JSON-serializable AST nodes
  • Produces EXPLAIN AST output matching ClickHouse's format

About

No description, website, or topics provided.

Resources

Readme
MIT license

Contributing

Contributing
Activity
Custom properties

Stars

62 stars

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.