Skip to content

Clickhouse PrepareBatch splits column names on comma without respecting backticks #1827

@mdibaiee

Description

@mdibaiee

Observed

A call to PrepareBatch with queries that include a list of columns, splits columns on , but does not respect backticks. For example, if I have:

INSERT INTO my_table (col1, `my_weird,col2`, col3)

In https://github.com/ClickHouse/clickhouse-go/blob/main/batch.go#L29-L36, what happens is we get:

columns: {'col1', 'my_weird', 'col2', 'col3'}

And that causes:

requested column order is incorrect length to sort block - expected 3, got 4

Expected behaviour

Extracting column names in extractNormalizedInsertQueryAndColumns should respect backticks

Code example

package code

// your code snippet here

Error log

requested column order is incorrect length to sort block - expected 3, got 4

Details

Environment

  • clickhouse-go version: v2.43.0
  • Interface: database/sql compatible driver
  • Go version: 1.25.0
  • Operating system: macOS
  • ClickHouse version: 25.8
  • Is it a ClickHouse Cloud? No
  • ClickHouse Server non-default settings, if any: none
  • CREATE TABLE statements for tables involved:
  • Sample data for all these tables, use clickhouse-obfuscator if necessary

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions