From 0f053219b1ea53a9ba8624f0e8ea8ea8a5f6ffdb Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 30 Apr 2019 00:50:17 +0300 Subject: [PATCH] feat: Driver for ClickHouse database support (#94) * Initial work on ClickHouse driver * Update dependencies * added basic test including some fixes (#1) * Added tests and made some fixes * Generate custom query id * Add support for parameter placeholders * Enable join_use_nulls option * Add reference to ClickHouse driver * Add clickhouse option to the usage * Update documentation * Code formatting * Enable session per connection in the pool --- README.md | 1 + .../Connecting-to-the-Database.md | 15 +- docs/Cube.js-ClI/Reference.md | 2 +- packages/cubejs-cli/cubejsCli.js | 2 +- packages/cubejs-clickhouse-driver/.gitignore | 1 + .../cubejs-clickhouse-driver/CHANGELOG.md | 8 + packages/cubejs-clickhouse-driver/LICENSE | 202 ++++++++ packages/cubejs-clickhouse-driver/README.md | 18 + .../driver/ClickHouseDriver.js | 122 +++++ .../cubejs-clickhouse-driver/package.json | 26 + .../test/ClickHouseDriverTest.js | 146 ++++++ packages/cubejs-clickhouse-driver/yarn.lock | 465 ++++++++++++++++++ packages/cubejs-server-core/core/index.js | 3 +- 13 files changed, 1001 insertions(+), 10 deletions(-) create mode 100644 packages/cubejs-clickhouse-driver/.gitignore create mode 100644 packages/cubejs-clickhouse-driver/CHANGELOG.md create mode 100644 packages/cubejs-clickhouse-driver/LICENSE create mode 100644 packages/cubejs-clickhouse-driver/README.md create mode 100644 packages/cubejs-clickhouse-driver/driver/ClickHouseDriver.js create mode 100644 packages/cubejs-clickhouse-driver/package.json create mode 100644 packages/cubejs-clickhouse-driver/test/ClickHouseDriverTest.js create mode 100644 packages/cubejs-clickhouse-driver/yarn.lock diff --git a/README.md b/README.md index 473b76794ad53..fde70c91e63d2 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,7 @@ specifying the project name and your database using `-d` flag. Available options * `bigquery` * `redshift` * `mssql` +* `clickhouse` For example, diff --git a/docs/Cube.js-Backend/Connecting-to-the-Database.md b/docs/Cube.js-Backend/Connecting-to-the-Database.md index 4ae1d6de76aed..33382f0aca57d 100644 --- a/docs/Cube.js-Backend/Connecting-to-the-Database.md +++ b/docs/Cube.js-Backend/Connecting-to-the-Database.md @@ -9,13 +9,14 @@ Cube.js currently provides connectors to the following databases: | Database | Cube.js DB Type | | -------------------- |---------------- | -| PostgreSQL | postgres | -| MySQL | mysql | -| AWS Athena | athena | -| AWS Redshift | redshift | +| PostgreSQL | postgres | +| MySQL | mysql | +| AWS Athena | athena | +| AWS Redshift | redshift | | MongoDB (via MongoDB Connector for BI) | mongobi | -| Google BigQuery | bigquery | -| MS SQL | mssql | +| Google BigQuery | bigquery | +| MS SQL | mssql | +| ClickHouse | clickhouse | _If you'd like to connect to a database which is not yet supported, you can create a Cube.js-compilant driver package. [Here's a simple step-by-step guide](https://github.com/statsbotco/cube.js/blob/master/CONTRIBUTING.md#implementing-driver)._ @@ -38,7 +39,7 @@ The table below shows which environment variables are used for different databas | Database | Credentials | | -------------------- |--------------- | -| PostgreSQL, MySQL, AWS Redshift, MS SQL | `CUBEJS_DB_HOST`, `CUBEJS_DB_PORT`, `CUBEJS_DB_NAME`, `CUBEJS_DB_USER`, `CUBEJS_DB_PASS` | +| PostgreSQL, MySQL, AWS Redshift, MS SQL, ClickHouse | `CUBEJS_DB_HOST`, `CUBEJS_DB_PORT`, `CUBEJS_DB_NAME`, `CUBEJS_DB_USER`, `CUBEJS_DB_PASS` | | AWS Athena | `CUBEJS_AWS_KEY`, `CUBEJS_AWS_SECRET`, `CUBEJS_AWS_REGION`, `CUBEJS_AWS_S3_OUTPUT_LOCATION` | | Google Bigquery | `CUBEJS_DB_BQ_PROJECT_ID`, `CUBEJS_DB_BQ_KEY_FILE or CUBEJS_DB_BQ_CREDENTIALS` | | MongoDB | `CUBEJS_DB_HOST`, `CUBEJS_DB_NAME`, `CUBEJS_DB_PORT`, `CUBEJS_DB_USER`, `CUBEJS_DB_PASS`, `CUBEJS_DB_SSL`, `CUBEJS_DB_SSL_CA`, `CUBEJS_DB_SSL_CERT`, `CUBEJS_DB_SSL_CIPHERS`, `CUBEJS_DB_SSL_PASSPHRASE` | diff --git a/docs/Cube.js-ClI/Reference.md b/docs/Cube.js-ClI/Reference.md index c971c64419071..9b6f16a1d010a 100644 --- a/docs/Cube.js-ClI/Reference.md +++ b/docs/Cube.js-ClI/Reference.md @@ -19,7 +19,7 @@ $ cubejs create APP-NAME -d DB-TYPE [-t TEMPLATE] | Parameter | Description | Values | | --------- | ----------- | ------ | -| -d, --db-type | Preconfigure Cube.js app for selected database. | `postgres`, `mysql`, `athena`, `mongobi`, `bigquery`, `redshift`, `mssql` | +| -d, --db-type | Preconfigure Cube.js app for selected database. | `postgres`, `mysql`, `athena`, `mongobi`, `bigquery`, `redshift`, `mssql`, `clickhouse` | | -t, --template