Skip to content

Commit 6ad7b56

Browse files
kyleconroyclaude
andcommitted
Handle TernaryExpr with alias in WITH clause
Added case for TernaryExpr in explainWithElement to properly output the alias from WITH clause. Ternary expressions (? :) become Function if with the alias from the WITH element. Fixes stmt1 in 03254_uniq_exact_two_level_negative_zero. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f304b1d commit 6ad7b56

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

internal/explain/expressions.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,17 @@ func explainWithElement(sb *strings.Builder, n *ast.WithElement, indent string,
11421142
}
11431143
fmt.Fprintf(sb, "%s ExpressionList (children %d)\n", indent, 1)
11441144
Node(sb, e.Operand, depth+2)
1145+
case *ast.TernaryExpr:
1146+
// Ternary expressions become if functions with alias
1147+
if n.Name != "" {
1148+
fmt.Fprintf(sb, "%sFunction if (alias %s) (children %d)\n", indent, n.Name, 1)
1149+
} else {
1150+
fmt.Fprintf(sb, "%sFunction if (children %d)\n", indent, 1)
1151+
}
1152+
fmt.Fprintf(sb, "%s ExpressionList (children %d)\n", indent, 3)
1153+
Node(sb, e.Condition, depth+2)
1154+
Node(sb, e.Then, depth+2)
1155+
Node(sb, e.Else, depth+2)
11451156
default:
11461157
// For other types, just output the expression (alias may be lost)
11471158
Node(sb, n.Query, depth)
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt1": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)