ClickHouse / spark-clickhouse-connector

Spark ClickHouse Connector build on DataSourceV2 API
https://clickhouse.com/docs/en/integrations/apache-spark
Apache License 2.0
187 stars 66 forks source link

HTTPS Support #280

Closed rmehlitz closed 1 year ago

rmehlitz commented 1 year ago

Hello, I'm not sure if this is an actual issue or if I don't understand how it is supposed to work. But is there a possibility of using this connector with clickhouse cloud, so with a HTTPS connection?

If not, I think this could be really helpful.

pan3793 commented 1 year ago

This connector underlying uses the official clickhosue java client, so how do u achieve it through the official clickhosue java client?

rmehlitz commented 1 year ago

Well, I can pass a full jdbc url like: jdbc:clickhouse:http://localhost:8443?ssl=true&sslmode=STRICT (Source: https://clickhouse.com/docs/en/integrations/java#jdbc-driver)

But I don't see a way to put this in this connector, because host and port are split up

spark-shell \
--conf spark.sql.catalog.clickhouse=xenon.clickhouse.ClickHouseCatalog \
--conf spark.sql.catalog.clickhouse.host="<path-to-host>.clickhouse.cloud" \
--conf spark.sql.catalog.clickhouse.protocol=https \
--conf spark.sql.catalog.clickhouse.http_port=8443 \
--conf spark.sql.catalog.clickhouse.user=<user> \
--conf spark.sql.catalog.clickhouse.password=<pw> \
--conf spark.sql.catalog.clickhouse.database=<db name>\
--repositories https://repo.maven.apache.org/maven2/ \
--packages com.github.housepower:clickhouse-spark-runtime-3.4_2.12:0.7.2,com.clickhouse:clickhouse-jdbc:0.4.6

If it is that obvious, maybe you can point me to my mistake. Thanks

pan3793 commented 1 year ago

Try appending

--conf spark.sql.catalog.clickhouse.option.ssl=true \
--conf spark.sql.catalog.clickhouse.option.sslmode=STRICT \
rmehlitz commented 1 year ago

This works. Thank you!

pan3793 commented 1 year ago

thanks for the feedback, actually this question was asked a few times, in different approaches, someone asked how to pass custom options, and another guy asked how to enable SSL, let me update the docs to add it to the demo configurations