Skip to content

Commit 4c50282

Browse files
committed
Fix NULL::Type cast to keep Literal NULL format
When casting NULL with :: operator syntax (e.g. NULL::Nullable(UInt8)), output as Literal NULL rather than Literal \'NULL\'. Fixes many statements across 27 tests.
1 parent 141903c commit 4c50282

28 files changed

Lines changed: 37 additions & 152 deletions

File tree

internal/explain/functions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ func explainCastExprWithAlias(sb *strings.Builder, n *ast.CastExpr, alias string
336336
exprStr := formatExprAsString(lit)
337337
fmt.Fprintf(sb, "%s Literal \\'%s\\'\n", indent, exprStr)
338338
}
339+
} else if lit.Type == ast.LiteralNull {
340+
// NULL stays as Literal NULL, not formatted as a string
341+
fmt.Fprintf(sb, "%s Literal NULL\n", indent)
339342
} else {
340343
// Simple literal - format as string
341344
exprStr := formatExprAsString(lit)
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
{"explain_todo":{"stmt12":true,"stmt15":true,"stmt16":true,"stmt17":true,"stmt18":true,"stmt20":true}}
1+
{
2+
"explain_todo": {
3+
"stmt15": true,
4+
"stmt16": true,
5+
"stmt17": true,
6+
"stmt18": true
7+
}
8+
}

parser/testdata/00727_concat/metadata.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
"stmt19": true,
44
"stmt20": true,
55
"stmt44": true,
6-
"stmt46": true,
7-
"stmt62": true,
8-
"stmt63": true,
9-
"stmt64": true,
10-
"stmt65": true,
11-
"stmt66": true,
12-
"stmt67": true,
13-
"stmt83": true
6+
"stmt46": true
147
}
158
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt23": true
4-
}
5-
}
1+
{}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt5": true
4-
}
5-
}
1+
{}
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt1": true,
4-
"stmt3": true,
5-
"stmt5": true
6-
}
7-
}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"explain_todo":{"stmt5":true,"stmt6":true}}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"explain_todo":{"stmt10":true,"stmt11":true,"stmt12":true,"stmt9":true}}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"explain_todo":{"stmt61":true}}
1+
{}
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt27": true,
4-
"stmt28": true,
5-
"stmt29": true,
6-
"stmt3": true,
7-
"stmt30": true,
8-
"stmt4": true,
9-
"stmt7": true,
10-
"stmt82": true
11-
}
12-
}
1+
{}

0 commit comments

Comments
 (0)