extension-driver-clickhouse
This is the ClickHouse driver for VulcanSQL, provided by Canner.
Installation
-
Install the package:
npm i @vulcan-sql/extension-driver-clickhouse
-
Update your vulcan.yaml
file to enable the extension:
extensions:
clickhouse: '@vulcan-sql/extension-driver-clickhouse'
-
Create a new profile in your profiles.yaml
file or in the designated profile paths. For more information, please refer to the ClickHouse Client documentation for the available arguments.
- name: ch
type: clickhouse
connection:
host: 'www.example.com:8123'
request_timeout: 60000
max_open_connections: 10
compression:
response: true
request: false
username: 'user'
password: 'pass'
application: 'VulcanSQL'
database: 'hello-clickhouse'
clickhouse_settings:
allow_nullable_key: true
tls:
ca_cert: 'ca-cert-file-path'
cert: 'cert-file-path'
key: 'key-path'
session_id: ''
keep_alive:
enabled: true
socket_ttl: 2500
retry_on_expired_socket: false
The log
option is not included above because it requires defining a Logger class and assigning it. Therefore, it cannot be set through profiles.yaml
.
Note
ClickHouse supports parameterized queries to prevent SQL injection using prepared statements. Named placeholders are defined using the {name:type}
syntax. For more information, refer to the Query with Parameters section in the ClickHouse documentation.
However, the VulcanSQL API supports JSON format for API query parameters and does not support the full range of types available in ClickHouse. VulcanSQL only supports the conversion of the following types:
boolean
to ClickHouse type Bool
number
to ClickHouse types Int
or Float
string
to ClickHouse type String
Therefore, if you need to query data with special types in ClickHouse, such as Array(Unit8)
, Record<K, V>
, Date
, DateTime
, and so on, you can use ClickHouse Regular Functions or Type Conversion Functions to handle them.
Example:
SELECT * FROM users WHERE born_date = toDate({val:String});
⚠️ Caution
The ClickHouse driver currently does not support caching datasets. If you use the ClickHouse driver with caching dataset features, it will result in failure.
Testing
To run tests for the extension-driver-clickhouse
module, use the following command:
nx test extension-driver-clickhouse