housepower / ClickHouse-Native-JDBC

ClickHouse Native Protocol JDBC implementation
https://housepower.github.io/ClickHouse-Native-JDBC/
Apache License 2.0
523 stars 145 forks source link

[FEATURE]: Add clickhouse SSL\TLS connection #446

Closed dmitrybugakov closed 1 year ago

codecov[bot] commented 1 year ago

Codecov Report

Merging #446 (0ff8d5a) into master (df1eea2) will increase coverage by 0.40%. The diff coverage is 91.81%.

:exclamation: Current head 0ff8d5a differs from pull request most recent head 3e6761e. Consider uploading reports for the commit 3e6761e to get more accurate results

@@             Coverage Diff              @@
##             master     #446      +/-   ##
============================================
+ Coverage     62.99%   63.40%   +0.40%     
- Complexity     1263     1279      +16     
============================================
  Files           135      138       +3     
  Lines          6662     6760      +98     
  Branches        519      522       +3     
============================================
+ Hits           4197     4286      +89     
- Misses         2197     2205       +8     
- Partials        268      269       +1     
Files Changed Coverage Δ
...m/github/housepower/settings/ClickHouseConfig.java 76.96% <73.91%> (-0.89%) :arrow_down:
.../housepower/client/ssl/PermissiveTrustManager.java 75.00% <75.00%> (ø)
...ithub/housepower/client/ssl/SSLContextBuilder.java 93.54% <93.54%> (ø)
...ava/com/github/housepower/client/NativeClient.java 85.88% <100.00%> (+1.46%) :arrow_up:
...com/github/housepower/settings/KeyStoreConfig.java 100.00% <100.00%> (ø)
...ava/com/github/housepower/settings/SettingKey.java 99.33% <100.00%> (+0.02%) :arrow_up:
github-actions[bot] commented 1 year ago
BENCHMARK_REPORT
    1. Benchmark                                                  (batchSize)  (columnNum)  (selectNumber)  Mode  Cnt     Score   Error  Units
2. DoubleIBenchmark.benchInsertJdbc                                200000           20             N/A  avgt        293.397          ms/op
3. DoubleIBenchmark.benchInsertJdbc                                200000           50             N/A  avgt        722.798          ms/op
4. DoubleIBenchmark.benchInsertJdbc                                500000           20             N/A  avgt        729.168          ms/op
5. DoubleIBenchmark.benchInsertJdbc                                500000           50             N/A  avgt       1803.917          ms/op
6. DoubleIBenchmark.benchInsertNative                              200000           20             N/A  avgt        463.917          ms/op
7. DoubleIBenchmark.benchInsertNative                              200000           50             N/A  avgt       1205.343          ms/op
8. DoubleIBenchmark.benchInsertNative                              500000           20             N/A  avgt       1175.316          ms/op
9. DoubleIBenchmark.benchInsertNative                              500000           50             N/A  avgt       3167.000          ms/op
10. InsertIBenchmark.benchInsertJdbc                                200000           20             N/A  avgt        197.034          ms/op
11. InsertIBenchmark.benchInsertJdbc                                200000           50             N/A  avgt        196.392          ms/op
12. InsertIBenchmark.benchInsertJdbc                                500000           20             N/A  avgt        455.301          ms/op
13. InsertIBenchmark.benchInsertJdbc                                500000           50             N/A  avgt        465.454          ms/op
14. InsertIBenchmark.benchInsertNative                              200000           20             N/A  avgt        123.262          ms/op
15. InsertIBenchmark.benchInsertNative                              200000           50             N/A  avgt        125.469          ms/op
16. InsertIBenchmark.benchInsertNative                              500000           20             N/A  avgt        296.896          ms/op
17. InsertIBenchmark.benchInsertNative                              500000           50             N/A  avgt        287.857          ms/op
18. IntIBenchmark.benchInsertJdbc                                   200000           20             N/A  avgt        255.699          ms/op
19. IntIBenchmark.benchInsertJdbc                                   200000           50             N/A  avgt        595.313          ms/op
20. IntIBenchmark.benchInsertJdbc                                   500000           20             N/A  avgt        582.641          ms/op
21. IntIBenchmark.benchInsertJdbc                                   500000           50             N/A  avgt       1398.977          ms/op
22. IntIBenchmark.benchInsertNative                                 200000           20             N/A  avgt        426.258          ms/op
23. IntIBenchmark.benchInsertNative                                 200000           50             N/A  avgt       1090.610          ms/op
24. IntIBenchmark.benchInsertNative                                 500000           20             N/A  avgt        992.348          ms/op
25. IntIBenchmark.benchInsertNative                                 500000           50             N/A  avgt       2542.091          ms/op
26. SelectIBenchmark.benchSelectJdbc                                   N/A          N/A          500000  avgt        389.465          ms/op
27. SelectIBenchmark.benchSelectJdbc                                   N/A          N/A        10000000  avgt       6818.356          ms/op
28. SelectIBenchmark.benchSelectNative                                 N/A          N/A          500000  avgt        361.328          ms/op
29. SelectIBenchmark.benchSelectNative                                 N/A          N/A        10000000  avgt       6396.659          ms/op
30. StringIBenchmark.benchInsertJdbc                                200000           20             N/A  avgt        716.884          ms/op
31. StringIBenchmark.benchInsertJdbc                                200000           50             N/A  avgt       1671.943          ms/op
32. StringIBenchmark.benchInsertJdbc                                500000           20             N/A  avgt       1655.459          ms/op
33. StringIBenchmark.benchInsertJdbc                                500000           50             N/A  avgt       4147.418          ms/op
34. StringIBenchmark.benchInsertNative                              200000           20             N/A  avgt        757.234          ms/op
35. StringIBenchmark.benchInsertNative                              200000           50             N/A  avgt       1961.602          ms/op
36. StringIBenchmark.benchInsertNative                              500000           20             N/A  avgt       1979.717          ms/op
37. StringIBenchmark.benchInsertNative                              500000           50             N/A  avgt       4876.426          ms/op
38. WideColumnDoubleInsertIBenchmark.benchInsertJdbc                200000           20             N/A  avgt        298.535          ms/op
39. WideColumnDoubleInsertIBenchmark.benchInsertJdbc                200000           50             N/A  avgt        762.298          ms/op
40. WideColumnDoubleInsertIBenchmark.benchInsertJdbc                500000           20             N/A  avgt        680.221          ms/op
41. WideColumnDoubleInsertIBenchmark.benchInsertJdbc                500000           50             N/A  avgt       1961.005          ms/op
42. WideColumnDoubleInsertIBenchmark.benchInsertNative              200000           20             N/A  avgt        502.772          ms/op
43. WideColumnDoubleInsertIBenchmark.benchInsertNative              200000           50             N/A  avgt       1230.842          ms/op
44. WideColumnDoubleInsertIBenchmark.benchInsertNative              500000           20             N/A  avgt       1202.025          ms/op
45. WideColumnDoubleInsertIBenchmark.benchInsertNative              500000           50             N/A  avgt       2998.804          ms/op
46. WideColumnIntInsertIBenchmark.benchInsertJdbc                   200000           20             N/A  avgt        233.050          ms/op
47. WideColumnIntInsertIBenchmark.benchInsertJdbc                   200000           50             N/A  avgt        556.819          ms/op
48. WideColumnIntInsertIBenchmark.benchInsertJdbc                   500000           20             N/A  avgt        573.165          ms/op
49. WideColumnIntInsertIBenchmark.benchInsertJdbc                   500000           50             N/A  avgt       1310.190          ms/op
50. WideColumnIntInsertIBenchmark.benchInsertNative                 200000           20             N/A  avgt        400.072          ms/op
51. WideColumnIntInsertIBenchmark.benchInsertNative                 200000           50             N/A  avgt       1053.809          ms/op
52. WideColumnIntInsertIBenchmark.benchInsertNative                 500000           20             N/A  avgt        958.801          ms/op
53. WideColumnIntInsertIBenchmark.benchInsertNative                 500000           50             N/A  avgt       2464.366          ms/op
54. WideColumnStringInsertIBenchmark.benchInsertJdbc                200000           20             N/A  avgt        686.281          ms/op
55. WideColumnStringInsertIBenchmark.benchInsertJdbc                200000           50             N/A  avgt       1661.650          ms/op
56. WideColumnStringInsertIBenchmark.benchInsertJdbc                500000           20             N/A  avgt       1709.741          ms/op
57. WideColumnStringInsertIBenchmark.benchInsertJdbc                500000           50             N/A  avgt       4246.089          ms/op
58. WideColumnStringInsertIBenchmark.benchInsertNative              200000           20             N/A  avgt        762.238          ms/op
59. WideColumnStringInsertIBenchmark.benchInsertNative              200000           50             N/A  avgt       1944.763          ms/op
60. WideColumnStringInsertIBenchmark.benchInsertNative              500000           20             N/A  avgt       1957.203          ms/op
61. WideColumnStringInsertIBenchmark.benchInsertNative              500000           50             N/A  avgt       5059.275          ms/op
  
paf91 commented 5 months ago

sorry to bother you after PR is completed, but where is any documentation of how to use it? @dmitrybugakov I'm trying with pyspark:

df.write\
    .format("jdbc")\
    .mode("append")\
    .option("driver", "com.github.housepower.jdbc.ClickHouseDriver")\
    .option("url", "jdbc:clickhouse://private-server:9440")\
    .option("user", user)\
    .option("password", password)\
    .option("dbtable", "test.test1")\
    .option("truncate", "false")\
    .option("batchsize", 10000)\
    .option("isolationLevel", "NONE")\
    .save()

nevermind, figured out it's simply as

df.write\
    .format("jdbc")\
    .mode("append")\
    .option("driver", "com.github.housepower.jdbc.ClickHouseDriver")\
    .option("url", "jdbc:clickhouse://private-server:9440?&ssl=true")\
    .option("user", user)\
    .option("password", password)\
    .option("dbtable", "test.test1")\
    .option("truncate", "false")\
    .option("batchsize", 10000)\
    .option("isolationLevel", "NONE")\
    .save()
dmitrybugakov commented 5 months ago

Hello @paf91

Unfortunately, there is a gap in our documentation regarding SSL connections.

However, you can use this test as an example.