Skip to content

Commit 2bb62d2

Browse files
committed
Fix spark lambdas
1 parent c75a4ac commit 2bb62d2

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/main/java/com/github/vertical_blank/sqlformatter/languages/SparkSqlFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public DialectConfig dialectConfig() {
252252
.indexedPlaceholderTypes(Collections.singletonList("?"))
253253
.namedPlaceholderTypes(Collections.singletonList("$"))
254254
.lineCommentTypes(Collections.singletonList("--"))
255-
.operators(Arrays.asList("!=", "<=>", "&&", "||", "=="))
255+
.operators(Arrays.asList("!=", "<=>", "&&", "||", "==", "->"))
256256
.build();
257257
}
258258

src/test/java/com/github/vertical_blank/sqlformatter/SqlFormatterTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,10 @@ public void withIndexedParams() {
7575
String format = SqlFormatter.format("SELECT * FROM tbl WHERE foo = ?", Arrays.asList("'bar'"));
7676
assertEquals(format, "SELECT\n" + " *\n" + "FROM\n" + " tbl\n" + "WHERE\n" + " foo = 'bar'");
7777
}
78+
79+
@Test
80+
public void withLambdasParams() {
81+
String format = SqlFormatter.of(Dialect.SparkSql).format("SELECT aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x, acc -> acc * 10);");
82+
assertEquals(format, "SELECT\n" + " aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x, acc -> acc * 10);");
83+
}
7884
}

src/test/kotlin/com/github/vertical_blank/sqlformatter/SparkSqlFormatterTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object SparkSqlFormatterTest :
3131
supportsSchema(formatter)
3232
supportsOperators(
3333
formatter,
34-
listOf("!=", "%", "|", "&", "^", "~", "!", "<=>", "%", "&&", "||", "==")
34+
listOf("!=", "%", "|", "&", "^", "~", "!", "<=>", "%", "&&", "||", "==", "->")
3535
)
3636
supportsJoin(
3737
formatter,

0 commit comments

Comments
 (0)