Repository navigation
Closed
Description
Input data
Which SQL and options did you provide as input?
// npm i [email protected]
const { format } = require('sql-formatter');
// 1. DuckDB: list overlap (&&), array distance (<->), list contains (@>, <@)
console.log(format('SELECT [1, 2, 3] && [3, 4], a <-> b', { language: 'duckdb' }));
format('SELECT [1, 2, 3] @> [1]', { language: 'duckdb' });
format('SELECT [1] <@ [1, 2]', { language: 'duckdb' });
// 2. Spark: bitwise shifts (<<, >>, >>>), named argument (=>), cast (::)
console.log(format('SELECT a << 1, a >> 1, a >>> 1, f(x => 1)', { language: 'spark' }));
format('SELECT a::INT', { language: 'spark' });
// 3. Redshift: LIKE synonym (~~) and negated POSIX regex (!~)
console.log(format('SELECT a ~~ b', { language: 'redshift' }));
format('SELECT a !~ b', { language: 'redshift' });
// 4. Transact-SQL: string concatenation (||)
console.log(format("SELECT 'SQL ' || 'Server'", { language: 'transactsql' }));Expected Output
-- 1. DuckDB
SELECT
[1, 2, 3] && [3, 4],
a <-> b
SELECT
[1, 2, 3] @> [1]
SELECT
[1] <@ [1, 2]
-- 2. Spark
SELECT
a << 1,
a >> 1,
a >>> 1,
f (x => 1)
SELECT
a::INT
-- 3. Redshift
SELECT
a ~~ b
SELECT
a !~ b
-- 4. Transact-SQL
SELECT
'SQL ' || 'Server'Actual Output
-- 1. DuckDB
SELECT
[1, 2, 3] & & [3, 4],
a < -> b
-- Parse error: Unexpected "@> [1]" at line 1 column 18. SQL dialect used: "duckdb".
-- Parse error: Unexpected "@ [1, 2]" at line 1 column 13. SQL dialect used: "duckdb".
-- 2. Spark
SELECT
a < < 1,
a > > 1,
a > > > 1,
f (x = > 1)
-- Parse error: Unexpected "::INT" at line 1 column 9. SQL dialect used: "spark".
-- 3. Redshift
SELECT
a ~ ~ b
-- Parse error: Unexpected "!~ b" at line 1 column 10. SQL dialect used: "redshift".
-- 4. Transact-SQL
SELECT
'SQL ' | | 'Server'Usage
- Calling
format(sql, { language })in Node.js (can also be reproduced per dialect on https://sql-formatter-org.github.io/sql-formatter by selecting the corresponding language). - Applies to
duckdb,spark,redshift, andtransactsqldialects, where these operators are missing from each dialect'soperatorslist insrc/languages/<dialect>/<dialect>.formatter.ts:- DuckDB:
&&,@>,<@(list functions) and<->(array functions) - Spark:
<<,>>,>>>,::(operators) and=>(named argument invocation) - Redshift:
~~and!~(POSIX operators) - Transact-SQL:
||(string concatenation)
- DuckDB:
- Version:
[email protected](also reproduced onmasterate73547e).
Found with a differential-testing tool; the report was drafted with AI assistance and reviewed and edited by me.
Credit: https://ucsbplse.github.io/
Metadata
Metadata
Assignees
Labels
No labels
Activity
Merge branch 'missing-operators'