sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.48k stars 805 forks source link

Add Clickhouse support #1628

Open bojdell opened 2 years ago

bojdell commented 2 years ago

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:

What database engines need to be changed?

No response

What programming language backends need to be changed?

No response

bojdell commented 2 years ago

@kyleconroy was there an outcome of the triaging?

bojdell commented 2 years ago

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?

cqhung1412 commented 1 year ago

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

nexovec commented 11 months ago

Are you guys considering this?

matthewshirley commented 8 months ago

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

Support was also dropped for the ANTLR4 files:

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

w0rp commented 4 months ago

I'm very much interested in having this as a feature, as I'd like to use this library to build tools that use ClickHouse as the only SQL-like database.

1saifj commented 1 month ago

Sqlc supporting Clickhouse is a big addition!.