sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Add Clickhouse support

Open bojdell opened this issue 3 years ago • 19 comments

What do you want to change?

I've enjoyed using sqlc with postgres. However, I'm starting to do more work with Clickhouse and it would be great to also use sqlc there. I imagine this is a similar ask to https://github.com/kyleconroy/sqlc/issues/161 for sqlite and the core work required is integrating a query parser for ClickHouse. I don't have much experience in this area, but here is some potentially related content that may be helpful:

  • https://github.com/ClickHouse/ClickHouse/issues/7595
  • https://github.com/ClickHouse/ClickHouse/pull/11298

What database engines need to be changed?

No response

What programming language backends need to be changed?

No response

bojdell avatar May 17 '22 20:05 bojdell

@kyleconroy was there an outcome of the triaging?

bojdell avatar Jul 15 '22 20:07 bojdell

An alternate solution that's likely easier to implement is to add an argument to bypass schema validation - aka allow query generation without statically checking the queries against the schema and let the user rely on test codepaths to ensure correctness of the logic. Obviously using the argument would sacrifice safety but gain flexibility, enabling support for any ANSI SQL driver. Thoughts?

bojdell avatar Jul 18 '22 19:07 bojdell

Hi, @kyleconroy I'd like to ask if there is any progress on this.

cqhung1412 avatar Sep 11 '23 06:09 cqhung1412

Are you guys considering this?

nexovec avatar Dec 16 '23 18:12 nexovec

I was also curious, but I don't think it is possible with the provided ANTLR4, as the output for Go is unusable:

  • https://github.com/ClickHouse/ClickHouse/issues/31650
    • https://github.com/antlr/antlr4/pull/3299

Support was also dropped for the ANTLR4 files:

  • https://github.com/ClickHouse/ClickHouse/pull/25942

Seems that a similar pattern to Postgres could be used with this clickhouse-sql-parser (https://github.com/AfterShip/clickhouse-sql-parser).

matthewshirley avatar Mar 21 '24 07:03 matthewshirley