Skip to content

Commit 573640a

Browse files
committed
Fix EXPLAIN prefix format and enable 11 more tests (#22)
EXPLAIN output fix: - At top level, ClickHouse outputs "Explain EXPLAIN <TYPE>" - Nested in subqueries, it outputs "Explain <TYPE>" - Added depth check to handle both cases correctly - Also fixed EXPLAIN CURRENT TRANSACTION case Tests enabled: - 01029_early_constant_folding - 01840_tupleElement_formatting_fuzzer - 02210_processors_profile_log - 02220_array_join_format - 02315_replace_multiif_to_if - 02377_executable_function_settings - 02477_is_null_parser - 02752_is_null_priority - 02889_system_drop_format_schema - 02893_system_drop_schema_cache_format - 03155_explain_current_transaction
1 parent da5557a commit 573640a

File tree

12 files changed

+24
-13
lines changed

12 files changed

+24
-13
lines changed

internal/explain/statements.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,21 @@ func explainSystemQuery(sb *strings.Builder, indent string) {
297297
func explainExplainQuery(sb *strings.Builder, n *ast.ExplainQuery, indent string, depth int) {
298298
// EXPLAIN CURRENT TRANSACTION has no children
299299
if n.ExplainType == ast.ExplainCurrentTransaction {
300-
fmt.Fprintf(sb, "%sExplain %s\n", indent, n.ExplainType)
300+
// At top level (depth 0), ClickHouse outputs "Explain EXPLAIN <TYPE>"
301+
if depth == 0 {
302+
fmt.Fprintf(sb, "%sExplain EXPLAIN %s\n", indent, n.ExplainType)
303+
} else {
304+
fmt.Fprintf(sb, "%sExplain %s\n", indent, n.ExplainType)
305+
}
301306
return
302307
}
303-
fmt.Fprintf(sb, "%sExplain %s (children %d)\n", indent, n.ExplainType, 1)
308+
// At top level (depth 0), ClickHouse outputs "Explain EXPLAIN <TYPE>"
309+
// Nested in subqueries, it outputs "Explain <TYPE>"
310+
if depth == 0 {
311+
fmt.Fprintf(sb, "%sExplain EXPLAIN %s (children %d)\n", indent, n.ExplainType, 1)
312+
} else {
313+
fmt.Fprintf(sb, "%sExplain %s (children %d)\n", indent, n.ExplainType, 1)
314+
}
304315
Node(sb, n.Statement, depth+1)
305316
}
306317

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}

0 commit comments

Comments
 (0)