You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Named placeholders are broken due to whitespace #57
Seeing a similar issue with parameter injection, depending on the dialect.
When using TSql parameter injection works, when using StandardSql, SparkSql, and maybe others, an extra whitespace is added, and parameter injection does not work:
// Bad exampleSqlFormatter.of(Dialect.SparkSql).format("@thing", Map.of("thing", "foo")); // Result: "@ thing"// Good exampleSqlFormatter.of(Dialect.TSql).format("@thing", Map.of("thing", "foo")); // Result: "foo"
If anyone bumps into this issue, a possible workaround is to add '@' as a named placeholder type:
FormattersparkSqlFormatter = SqlFormatter
.of(Dialect.SparkSql)
// Required for named placeholders to work
.extend(dialectConfig -> dialectConfig.plusNamedPlaceholderTypes("@"));
// ... any other needed extensions
Activity
michaelborn commentedon Apr 21, 2022
Note that positional placeholders are still formatted and replace correctly.
ItayPolackGadassiAkamai commentedon Jan 10, 2024
Seeing a similar issue with parameter injection, depending on the dialect.
When using TSql parameter injection works, when using StandardSql, SparkSql, and maybe others, an extra whitespace is added, and parameter injection does not work:
ItayPolackGadassiAkamai commentedon Jan 10, 2024
If anyone bumps into this issue, a possible workaround is to add
'@'as a named placeholder type: