Skip to content

Commit

Permalink
Merge pull request #65 from NathanEckert/fix/spark_lambdas
Browse files Browse the repository at this point in the history
Fix spark lambdas
  • Loading branch information
vertical-blank authored May 25, 2023
2 parents c75a4ac + 0d9aa91 commit 5120732
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public DialectConfig dialectConfig() {
.indexedPlaceholderTypes(Collections.singletonList("?"))
.namedPlaceholderTypes(Collections.singletonList("$"))
.lineCommentTypes(Collections.singletonList("--"))
.operators(Arrays.asList("!=", "<=>", "&&", "||", "=="))
.operators(Arrays.asList("!=", "<=>", "&&", "||", "==", "->"))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,14 @@ public void withIndexedParams() {
String format = SqlFormatter.format("SELECT * FROM tbl WHERE foo = ?", Arrays.asList("'bar'"));
assertEquals(format, "SELECT\n" + " *\n" + "FROM\n" + " tbl\n" + "WHERE\n" + " foo = 'bar'");
}

@Test
public void withLambdasParams() {
String format =
SqlFormatter.of(Dialect.SparkSql)
.format("SELECT aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x, acc -> acc * 10);");
assertEquals(
format,
"SELECT\n" + " aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x, acc -> acc * 10);");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object SparkSqlFormatterTest :
supportsSchema(formatter)
supportsOperators(
formatter,
listOf("!=", "%", "|", "&", "^", "~", "!", "<=>", "%", "&&", "||", "==")
listOf("!=", "%", "|", "&", "^", "~", "!", "<=>", "%", "&&", "||", "==", "->")
)
supportsJoin(
formatter,
Expand Down

0 comments on commit 5120732

Please sign in to comment.