Skip to content

Commit 7bf233f

Browse files
kyleconroyclaude
andcommitted
Eliminate unary plus from AST (no-op in ClickHouse) (#122)
In ClickHouse, unary plus (+x) is a no-op and doesn't appear in the EXPLAIN AST output. Updated parseUnaryPlus to simply return the operand without wrapping it in a UnaryExpr. This fixes parsing of expressions like (+c0.2) which should produce just tupleElement, not Function + wrapping tupleElement. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 96db89a commit 7bf233f

File tree

5 files changed

+7
-27
lines changed

5 files changed

+7
-27
lines changed

parser/expression.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,13 +1167,9 @@ func (p *Parser) parseUnaryPlus() ast.Expression {
11671167
}
11681168
}
11691169

1170-
// Standard unary plus handling
1171-
expr := &ast.UnaryExpr{
1172-
Position: pos,
1173-
Op: "+",
1174-
}
1175-
expr.Operand = p.parseExpression(UNARY)
1176-
return expr
1170+
// In ClickHouse, unary plus is a no-op and doesn't appear in EXPLAIN AST.
1171+
// Simply return the operand without wrapping it in UnaryExpr.
1172+
return p.parseExpression(UNARY)
11771173
}
11781174

11791175
func (p *Parser) parseNot() ast.Expression {
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt4": 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-
"stmt14": 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-
"stmt14": 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-
"stmt1": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)