-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Support ClickHouse driver #221
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportPatch coverage has no change and project coverage change:
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## develop #221 +/- ##
===========================================
- Coverage 90.52% 90.50% -0.02%
===========================================
Files 331 331
Lines 5477 5477
Branches 732 732
===========================================
- Hits 4958 4957 -1
- Misses 374 375 +1
Partials 145 145
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
942adb3
to
ff3beda
Compare
- Create the "extension-driver-clickhouse" package - Create "ClickHouseDataSource". - update package.json to install "@clickhouse/client"
ff3beda
to
d84aece
Compare
d84aece
to
2681c5b
Compare
2681c5b
to
745eb52
Compare
745eb52
to
e72fc5b
Compare
e72fc5b
to
4d5456d
Compare
4d5456d
to
43dee2b
Compare
43dee2b
to
135dfb5
Compare
…ng method - add clickhouse server for running test cases by docker. - refactor clickhouse data source by querying data with column name and evaluating column with type by "describe" method. - set "testEnvironment" to "node" in jest environment to make clickhouse client could work when running test cases. - fix typeMapper for converting "Bool" to "boolean"
…lickhouse documentation content and syntax.
…nsion-driver-clickhouse
…e server docker name may not conflict
…khouse type - normalize to convert to Bool clickhouse type. - change to use number to prevent docker name duplicated. - update README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the Makefile part, Others LGTM and can be merged.
@@ -56,6 +56,15 @@ pkg-extension-authenticator-canner: ../../node_modules | |||
rm -rf ./labs/playground1/node_modules/@vulcan-sql/extension-authenticator-canner; \ | |||
cp -R ./dist/packages/extension-authenticator-canner ./labs/playground1/node_modules/@vulcan-sql | |||
|
|||
pkg-extension-driver-clickhouse: ../../node_modules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary? It seems like the vulcan.yaml didn't use the clickhouse extension
Description
Support ClickHouse driver to connect ClickHouse data source via ClickHouse Official Node driver.
Please read the README to know How to use it
Issue ticket number
closes #183
How to test it by
labs
Create ClickHouse and prepare data.
Set the database, username, and password by Docker's environment. See Docker image to know more information
The ClickHouse
8123
port is used for HTTP API Port for HTTP requests. used by JDBC, ODBC, and web interfaces. Therefore our node ClickHouse could connect it, for more information about other ports, see Network portsexec
enter to the container$ docker exec -it c36639dcb36e /bin/bash root@c36639dcb36e:/$
clickhouse-client
to the session in the container and useSHOW TABLES
to make it workdb
schema.Then query all to make the data inserted
Add sample to
/labs
make
and make sure yournode_modules
has@clickhouse/client
andextension-driver-clickhouse
under@vulcan-sql
directory.extension-driver-clickhouse
in thevulcan.yarml
profile.yaml
:vulcan start
:Filename:
my_first_table.sql
Filename:
my_first_table.yaml
:Then type
vulcan start
:/api/clickhouse/my_first_table
to see all data:/api/clickhouse/my_first_table?id=101
to see the filter result:Additional Context
Currently, the caching dataset feature is not supported.
The ClickHouse driver does not currently implement the
export
method for exporting Parquet files. As a result, it does not yet support caching datasets. If you attempt to use the ClickHouse driver with the caching dataset feature, it will fail.How to handle scenarios where ClickHouse cannot provide both the column name and type simultaneously, as well as JSON data containing field names.
The ClickHouse client does not support retrieving column names, types, and data rows together when using the JSON format. However, by using the
JSONCompactEachRowWithNamesAndTypes
format, we can obtain column names, types, and data rows as an array-like structure, as shown below:Therefore, it is necessary to normalize each data row and include the corresponding column name in the JSON object.
However, there is a cost associated with this approach. As an alternative solution, we can choose the
JSONEachRow
format to retrieve the data rows with column names using an array JSON object. To determine the return type without executing the query or retrieving the data, we can utilize theDESCRIBE TABLE (subquery)
syntax. This method will only evaluate the return type instead of executing the query and returning the data.Retrieving the column name and type by
DESCRIBE TABLE (subquery)
:Getting the query results through using
JSONEachRow
format, its array JSON object:How to handle the issue of ClickHouse Driver using specific names and types as placeholders ({name:type})
The ClickHouse driver utilizes specific names and types as placeholders (
{name:type}
). Please refer to the documentation for more details on handling parameterized queries to prevent SQL injection. However, ClickHouse supports a variety of data types that cannot be directly inferred from JSON types. Therefore, in themapToClickHouseType
method, the driver only handles the following conversions and requires users to use ClickHouse Regular Functions or Type Conversion Functions for other conversions. Please see the Note for more information:boolean
toBool
ClickHouse typenumber
toInt
orFloat
ClickHouse typestring
toString
ClickHouse typePS: When defining column type or query result with the parameterized query, The
Bool
orBoolean
type is both supported, but the column type of query result only returnsBool
, so we only supportBool
type for safety.