Skip to content

Commit

Permalink
Fix spark lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
hogimn committed Jan 21, 2024
1 parent 0d572b6 commit 210cb5c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion SQL.Formatter.Test/SparkSqlFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public void OperatorsTest()
"%",
"&&",
"||",
"=="
"==",
"->"
});
}

Expand Down
12 changes: 12 additions & 0 deletions SQL.Formatter.Test/SqlFormatterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,17 @@ public void WithIndexedParams()
+ " foo = 'bar'",
format);
}

[Fact]
public void WithLambdasParams()
{
var format = SqlFormatter
.Of(Dialect.SparkSql)
.Format("SELECT aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x, acc -> acc * 10);");
Assert.Equal(
"SELECT\n"
+ " aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x, acc -> acc * 10);",
format);
}
}
}
2 changes: 1 addition & 1 deletion SQL.Formatter/Language/SparkSqlFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public override DialectConfig DoDialectConfig()
.IndexedPlaceholderTypes(new List<string> { "?" })
.NamedPlaceholderTypes(new List<string> { "$" })
.LineCommentTypes(new List<string> { "--" })
.Operators(new List<string> { "!=", "<=>", "&&", "||", "==" })
.Operators(new List<string> { "!=", "<=>", "&&", "||", "==", "->" })
.Build();
}

Expand Down

0 comments on commit 210cb5c

Please sign in to comment.