Skip to content

Commit 03c44b0

Browse files
kyleconroyclaude
andcommitted
Fix column declaration child order in EXPLAIN output
Reorder column declaration children to match ClickHouse's EXPLAIN AST: 1. Type 2. Settings (SETTINGS clause) 3. Default value 4. TTL 5. Codec 6. Statistics 7. Comment Previously Settings was output after TTL and Statistics, but ClickHouse outputs it right after the type. Fixes test: 03270_fix_column_modifier_write_order/stmt3 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 619c89d commit 03c44b0

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

internal/explain/explain.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,9 @@ func Column(sb *strings.Builder, col *ast.ColumnDeclaration, depth int) {
357357
if col.Type != nil {
358358
Node(sb, col.Type, depth+1)
359359
}
360-
if len(col.Statistics) > 0 {
361-
explainStatisticsExpr(sb, col.Statistics, indent+" ", depth+1)
360+
// Settings comes right after Type in ClickHouse EXPLAIN output
361+
if len(col.Settings) > 0 {
362+
fmt.Fprintf(sb, "%s Set\n", indent)
362363
}
363364
if col.Default != nil {
364365
Node(sb, col.Default, depth+1)
@@ -372,8 +373,8 @@ func Column(sb *strings.Builder, col *ast.ColumnDeclaration, depth int) {
372373
if col.Codec != nil {
373374
explainCodecExpr(sb, col.Codec, indent+" ", depth+1)
374375
}
375-
if len(col.Settings) > 0 {
376-
fmt.Fprintf(sb, "%s Set\n", indent)
376+
if len(col.Statistics) > 0 {
377+
explainStatisticsExpr(sb, col.Statistics, indent+" ", depth+1)
377378
}
378379
if col.Comment != "" {
379380
fmt.Fprintf(sb, "%s Literal \\'%s\\'\n", indent, col.Comment)
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt3": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)