Skip to content
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

JDBC bridge + bigquery #154

Open
andaag opened this issue Jul 5, 2022 · 4 comments
Open

JDBC bridge + bigquery #154

andaag opened this issue Jul 5, 2022 · 4 comments
Labels
question Further information is requested

Comments

@andaag
Copy link

andaag commented Jul 5, 2022

So, I'd love for some official documentation on how to combine this with bigquery's jdbc bridge.

I just tested this... and surprisingly it works. Essentially just dumped all the jar files from the bigquery connector (issue pending to publish it in maven... currently a zip download) into the drivers directory, and set up a source for it.

{
  "$schema": "../../../../../docker/config/datasource.jschema",
  "bigquery": {
    "driverClassName": "com.simba.googlebigquery.jdbc.Driver",
    "jdbcUrl": "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=nansen-endpoints-dev;OAuthType=0;OAuthPvtKeyPath=/app/bigquery/sa.json;OAuthServiceAcctEmail=SERVICE_ACCOUNT@PROJECT_ID.iam.gserviceaccount.com",
    "initializationFailTimeout": 0,
    "minimumIdle": 0,
    "maximumPoolSize": 10
  }
}

This for us might be an interesting option. We're looking into some data sync jobs between bigquery and clickhouse, and it would allow us to use dbt materialized views for this for example. Probably wouldn't be optimal performance, but in terms of ease of use for our developers it would be a pretty interesting option.

How .. insane is this? It feels ... wrong. At the same time it did work fairly quickly. Is it worth spending the time to tuning timeouts and such to be able to use this to materialize bigquery data in clickhouse? I'd love to avoid our teams needing spark etc for this.

@zhicwu
Copy link
Contributor

zhicwu commented Jul 5, 2022

You're not crazy :) As long as the datasource has fully functional JDBC driver, you should be able to access that from ClickHouse, via JDBC bridge.

Probably wouldn't be optimal performance

The overhead of JDBC bridge is around 10% - 20% according to my test earlier, and it does not count the initial query for type inferring. However, I found it's acceptable for processing millions of rows or even near realtime monitoring(grafana + distributed query against various databases). In the case of cross-region data sync, it's actually faster than direct connect for some databases because of lz4 compression.

Is it worth spending the time to tuning timeouts and such to be able to use this to materialize bigquery data in clickhouse?

Unfortunately I'd suggest you limiting the usage for below reasons:

  1. JDBC bridge has issues in both design and implementation
  2. Timeout can be tricky
    • you have to consider many timeout settings: JDBC drivers, ClickHouse, and JDBC bridge
    • if you increase timeout for long running queries, small queries may hang for too long when there's network issue
    • and remember ClickHouse server can only connect to one JDBC bridge server(and you don't have much control over DNS-based load balancing)...
  3. Replace JDBC bridge by clickhouse-data-service(a new module in clickhouse-jdbc) in the future?
    It's just my personal opinion, but maybe it's better to implement a new data service using existing url table function along with enhanced JDBC driver for more features(like access control, query rewrite, encryption, data masking, zero configuration etc.) and better performance(less round trips). It may not be fully backward compatible.

@zhicwu zhicwu added the question Further information is requested label Jul 5, 2022
@andaag
Copy link
Author

andaag commented Jul 5, 2022

Thanks for the detailed writeup!

Can you link me to some more information on clickhouse-data-service ? Sounds very worth checking out.

@zhicwu
Copy link
Contributor

zhicwu commented Jul 5, 2022

Can you link me to some more information on clickhouse-data-service ?

Sorry it does not exist and I only mentioned it in ClickHouse/clickhouse-java#784 :p An alternative and more generic implementation as far as I know of, is trinodb/trino#1839.

@andaag
Copy link
Author

andaag commented Jul 6, 2022

Alright, thanks for your help!

I'll leave it up to you whether or not to leave this ticket as documentation or to close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants