Skip to content

[FORMATTING] Error when formatting Clickhouse SQL with Array column type #752

@eryx

Description

@eryx

Input data

Table Schema:

database: clickhouse

schema:

CREATE TABLE test_table_name (
  id String,
  array_column Array(String),
)
ENGINE = MergeTree()
PRIMARY KEY (id);

sql:

INSERT INTO test_table_name (id, array_column) VALUES ('unique-id', ['abc', 'def'])

Expected Output

guest@localhost% sql-formatter test.sql -o test.fmt.sql
/opt/homebrew/lib/node_modules/sql-formatter/dist/index.cjs:15909
    return new Error(
           ^

Error: Parse error: Unexpected "['abc', 'd" at line 1 column 69.
This likely happens because you're using the default "sql" dialect.
If possible, please select a more specific dialect (like sqlite, postgresql, etc).
    at TokenizerEngine.createParseError (/opt/homebrew/lib/node_modules/sql-formatter/dist/index.cjs:15909:12)
    at TokenizerEngine.tokenize (/opt/homebrew/lib/node_modules/sql-formatter/dist/index.cjs:15899:22)
    at Tokenizer.tokenize (/opt/homebrew/lib/node_modules/sql-formatter/dist/index.cjs:16019:65)
    at LexerAdapter.tokenize (/opt/homebrew/lib/node_modules/sql-formatter/dist/index.cjs:16856:37)
    at LexerAdapter.reset (/opt/homebrew/lib/node_modules/sql-formatter/dist/index.cjs:16391:24)
    at Parser.feed (/opt/homebrew/lib/node_modules/sql-formatter/node_modules/nearley/lib/nearley.js:281:15)
    at Object.parse (/opt/homebrew/lib/node_modules/sql-formatter/dist/index.cjs:16863:34)
    at Formatter.parse (/opt/homebrew/lib/node_modules/sql-formatter/dist/index.cjs:17572:49)
    at Formatter.format (/opt/homebrew/lib/node_modules/sql-formatter/dist/index.cjs:17567:22)
    at formatDialect (/opt/homebrew/lib/node_modules/sql-formatter/dist/index.cjs:17679:57)

Node.js v21.7.1

sql-formatter version 15.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions