Skip to content

Commit 3317a59

Browse files
committed
Add JSON output example and remove License section
1 parent 05f321b commit 3317a59

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package main
1515

1616
import (
1717
"context"
18+
"encoding/json"
1819
"fmt"
1920
"strings"
2021

@@ -31,6 +32,10 @@ func main() {
3132

3233
// Print EXPLAIN AST output (matches ClickHouse format)
3334
fmt.Println(parser.Explain(stmts[0]))
35+
36+
// Or serialize to JSON
37+
jsonBytes, _ := json.MarshalIndent(stmts[0], "", " ")
38+
fmt.Println(string(jsonBytes))
3439
}
3540
```
3641

@@ -58,14 +63,42 @@ SelectWithUnionQuery (children 1)
5863
Literal UInt64_10
5964
```
6065

66+
JSON output:
67+
68+
```json
69+
{
70+
"selects": [
71+
{
72+
"columns": [
73+
{ "parts": ["id"] },
74+
{ "parts": ["name"] }
75+
],
76+
"from": {
77+
"tables": [
78+
{ "table": { "table": { "table": "users" } } }
79+
]
80+
},
81+
"where": {
82+
"left": { "parts": ["active"] },
83+
"op": "=",
84+
"right": { "type": "Integer", "value": 1 }
85+
},
86+
"order_by": [
87+
{
88+
"expression": { "parts": ["created_at"] },
89+
"descending": true
90+
}
91+
],
92+
"limit": { "type": "Integer", "value": 10 }
93+
}
94+
]
95+
}
96+
```
97+
6198
## Features
6299

63100
- Parses SELECT, INSERT, CREATE, DROP, ALTER, and other ClickHouse statements
64101
- Handles ClickHouse-specific syntax (Array types, PREWHERE, SAMPLE, etc.)
65102
- Supports JOINs, subqueries, CTEs, window functions, and complex expressions
66103
- Generates JSON-serializable AST nodes
67104
- Produces EXPLAIN AST output matching ClickHouse's format
68-
69-
## License
70-
71-
MIT

0 commit comments

Comments
 (0)