Skip to content

Commit 8f1fd53

Browse files
committed
Add FORMAT clause output at SelectWithUnionQuery level
- Check if any SelectQuery in the union has a Format field - Output Format Identifier at SelectWithUnionQuery level (matches ClickHouse) - Update child count accordingly Tests passing: 5197 (up from 5179)
1 parent 77accb4 commit 8f1fd53

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

internal/explain/select.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ func explainSelectWithUnionQuery(sb *strings.Builder, n *ast.SelectWithUnionQuer
1515
for _, sel := range n.Selects {
1616
Node(sb, sel, depth+2)
1717
}
18+
// FORMAT clause - check if any SelectQuery has Format set
19+
for _, sel := range n.Selects {
20+
if sq, ok := sel.(*ast.SelectQuery); ok && sq.Format != nil {
21+
Node(sb, sq.Format, depth+1)
22+
break
23+
}
24+
}
1825
}
1926

2027
func explainSelectQuery(sb *strings.Builder, n *ast.SelectQuery, indent string, depth int) {
@@ -75,7 +82,15 @@ func explainOrderByElement(sb *strings.Builder, n *ast.OrderByElement, indent st
7582
}
7683

7784
func countSelectUnionChildren(n *ast.SelectWithUnionQuery) int {
78-
return 1 // ExpressionList of selects
85+
count := 1 // ExpressionList of selects
86+
// Check if any SelectQuery has Format set
87+
for _, sel := range n.Selects {
88+
if sq, ok := sel.(*ast.SelectQuery); ok && sq.Format != nil {
89+
count++
90+
break
91+
}
92+
}
93+
return count
7994
}
8095

8196
func countSelectQueryChildren(n *ast.SelectQuery) int {

0 commit comments

Comments
 (0)