-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add ClickHouse connector #4909
Add ClickHouse connector #4909
Conversation
@wgzhao could you possibly squash your commits and make sure the build is green? |
Can we have this on top of #5012 so that we can push table properties without extending JDBC metadata |
@wgzhao It looks like this is close. Can you rebase as @Praveen2112 suggested and squash the commits? |
#5012 has not merge, can I use it directly? |
...lickhouse/src/test/java/io/prestosql/plugin/clickhouse/TestClickHouseDistributedQueries.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/test/java/io/prestosql/plugin/clickhouse/TestingClickHouseServer.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/test/java/io/prestosql/plugin/clickhouse/ClickHouseQueryRunner.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseMetadata.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
@wgzhao can you please rebase and squash all commits into one? |
@wgzhao Please see https://docs.github.com/en/github/using-git/about-git-rebase BTW thanks for making sure the build is green! |
dc91581
to
4c10a90
Compare
@wgzhao note there is a compilation error in
|
@wgzhao I guess there is a small issue in merging. I'm not sure if |
4c10a90
to
50ee7ea
Compare
Yes, I remove all mistaken merging and re-commit |
Thank you , I have squash all commits into one commit |
Looks good to me, from a docs perspective. |
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseMetadata
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseMetadata.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseQueryBuilder.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseTableHandle.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseTableProperties.java
Outdated
Show resolved
Hide resolved
...lickhouse/src/test/java/io/prestosql/plugin/clickhouse/TestClickHouseDistributedQueries.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/test/java/io/prestosql/plugin/clickhouse/TestClickHousePlugin.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
presto-clickhouse/src/main/java/io/prestosql/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
...lickhouse/src/test/java/io/prestosql/plugin/clickhouse/TestClickHouseDistributedQueries.java
Outdated
Show resolved
Hide resolved
8213d89
to
dae1fb7
Compare
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Show resolved
Hide resolved
...no-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseDistributedQueries.java
Outdated
Show resolved
Hide resolved
...no-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseDistributedQueries.java
Outdated
Show resolved
Hide resolved
...no-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseDistributedQueries.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java
Show resolved
Hide resolved
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestingClickHouseServer.java
Show resolved
Hide resolved
526c37d
to
67a9c5d
Compare
@wgzhao please let me know when you address the comments. Also just FYI, the build is red currently. |
I try my best to address above comments on next week, thanks |
9e44c45
to
905c17c
Compare
@wgzhao are you working on any updates or is now waiting for my review? |
If it's convenient for you now, you can review first, we are still in the Chinese New Year holiday |
cdd1d7c
to
853f1b1
Compare
@wgzhao i am taking a closer look at type mappings and was trying to tie up some loose ends here However i realized i do not fully understand the idea behind String and FixedString in Clickhouse From the documentation that i found for String https://clickhouse.tech/docs/en/sql-reference/data-types/string/
And from FixedString docs https://clickhouse.tech/docs/en/sql-reference/data-types/fixedstring/ :
To me it sounds like we should map the both types to |
:) create table t (col FixedString(5)) ENGINE=TinyLog;
:) insert into t values('hell'),('中');
:) select * from t;
SELECT *
FROM t
┌─col──┐
│ hell │
│ 中 │
└──────┘
:) select * from t where col = '中\0\0';
SELECT *
FROM t
WHERE col = '中\0\0'
┌─col─┐
│ 中 │
└─────┘ My suggestion is for |
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.
Some comments.
You also need to add an entry to https://github.com/trinodb/trino/blob/master/core/trino-server/src/main/provisio/presto.xml to make sure the connector gets packaged into the final JAR.
import static java.util.Locale.ENGLISH; | ||
|
||
/** | ||
* The problem of incorrect catalog names kept tormenting me, I kept modifying it, overriding methods, |
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.
You can solve this by providing your own implementation of getTableHandle
.
The JdbcTableHandle created in getTableHandle
takes the catalog name as input.
Take a look at MySqlClient for example.
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.
This will also allow you to remove most of the overrides here.
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.
I tried it, But it brings up more errors
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Show resolved
Hide resolved
} | ||
|
||
@Override | ||
protected void renameTable(ConnectorSession session, String catalogName, String schemaName, String tableName, SchemaTableName newTable) |
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.
Override is not needed. If your JdbcTableHandle sets catalogname to empty optional then BaseJdbcClient#renameTable automatically constructs the proper SQL (including quoting).
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.
BaseJdbcClient#renameTable use ALTER TABLE RENAME TO
statement, But ClickHouse uses a different statment RENAME TABLE TO
. So, I had to override it.
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
@wgzhao I applied most of @hashhar's comments and tweaked the type mapping tests a bit. Also, i adapted the connector tests to the new base test class i recently introduced -- i didn't want to add more work on you because of changes done in the meantime. I also took liberty to swap the String, FixedString mapping into I posted #7081 and will merge when green. As this is the first version of the connector, there naturally is a bunch of things to take care of as follow ups. Thank you for your contribution, you did great job here and I am excited to see ClickHouse connector shipping soon! |
853f1b1
to
792abce
Compare
Thanks |
I deleted former PR( #4672) in my stupid operation.
The ClickHouse connector allows querying data stored in
Yandex ClickHouse
The ClickHouse connector is compatible with all ClickHouse versions starting from 20.3.5.21.
to view more details in presto-docs/clichouse.rst
Fixes #4500