Skip to content

Commit 210cb5c

Browse files
committed
Fix spark lambdas
1 parent 0d572b6 commit 210cb5c

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

SQL.Formatter.Test/SparkSqlFormatter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public void OperatorsTest()
7373
"%",
7474
"&&",
7575
"||",
76-
"=="
76+
"==",
77+
"->"
7778
});
7879
}
7980

SQL.Formatter.Test/SqlFormatterTest.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,17 @@ public void WithIndexedParams()
9595
+ " foo = 'bar'",
9696
format);
9797
}
98+
99+
[Fact]
100+
public void WithLambdasParams()
101+
{
102+
var format = SqlFormatter
103+
.Of(Dialect.SparkSql)
104+
.Format("SELECT aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x, acc -> acc * 10);");
105+
Assert.Equal(
106+
"SELECT\n"
107+
+ " aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x, acc -> acc * 10);",
108+
format);
109+
}
98110
}
99111
}

SQL.Formatter/Language/SparkSqlFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public override DialectConfig DoDialectConfig()
243243
.IndexedPlaceholderTypes(new List<string> { "?" })
244244
.NamedPlaceholderTypes(new List<string> { "$" })
245245
.LineCommentTypes(new List<string> { "--" })
246-
.Operators(new List<string> { "!=", "<=>", "&&", "||", "==" })
246+
.Operators(new List<string> { "!=", "<=>", "&&", "||", "==", "->" })
247247
.Build();
248248
}
249249

0 commit comments

Comments
 (0)