├── .github └── workflows │ └── release.yml ├── .gitignore ├── LICENSE ├── README.md ├── clickhouse_jdbc ├── Readme.md ├── connection-fields.xml ├── connection-metadata.xml ├── connectionBuilder.js ├── connectionProperties.js ├── connectionResolver.tdr ├── dialect.tdd └── manifest.xml └── signing_utility ├── pkcs11properties.cfg └── smpkcs11.so /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | on: 3 | workflow_dispatch: 4 | release: 5 | types: [created] 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout Tableau Connector Plugin SDK 11 | uses: actions/checkout@v3 12 | with: 13 | repository: tableau/connector-plugin-sdk 14 | ref: tableau-2023.2 15 | 16 | - name: Checkout ClickHouse Tableau JDBC connector 17 | uses: actions/checkout@v3 18 | with: 19 | path: clickhouse-tableau-jdbc 20 | 21 | - name: Set up Python 22 | uses: actions/setup-python@v4 23 | with: 24 | python-version: 3.9 25 | 26 | - name: Package the connector 27 | working-directory: connector-packager 28 | run: | 29 | python -m venv .venv 30 | source ./.venv/bin/activate 31 | python setup.py install 32 | python -m connector_packager.package ../clickhouse-tableau-jdbc/clickhouse_jdbc 33 | echo "TACO_FILE=$(find "$PWD" -name 'clickhouse*.taco' | head -n 1)" >> $GITHUB_ENV 34 | 35 | - name: Set up Java for signing 36 | uses: actions/setup-java@v3 37 | with: 38 | java-version: '11' 39 | distribution: 'zulu' 40 | 41 | - name: Prepare for signing 42 | working-directory: clickhouse-tableau-jdbc/signing_utility 43 | run: | 44 | cp ./smpkcs11.so /tmp/smpkcs11.so 45 | echo "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /tmp/Certificate_pkcs12.p12 46 | echo "SM_HOST=${{ secrets.SM_HOST }}" >> "$GITHUB_ENV" 47 | echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> "$GITHUB_ENV" 48 | echo "SM_CLIENT_CERT_FILE=/tmp/Certificate_pkcs12.p12" >> "$GITHUB_ENV" 49 | echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> "$GITHUB_ENV" 50 | echo "DIGICERT_KEY_ALIAS=${{ secrets.DIGICERT_KEY_ALIAS }}" >> "$GITHUB_ENV" 51 | shell: bash 52 | 53 | - name: Sign binary 54 | working-directory: clickhouse-tableau-jdbc/signing_utility 55 | run: | 56 | jarsigner -keystore NONE -storepass NONE -storetype PKCS11 -sigalg SHA256withRSA -providerClass sun.security.pkcs11.SunPKCS11 -providerArg pkcs11properties.cfg -signedjar clickhouse_jdbc_signed.taco $TACO_FILE $DIGICERT_KEY_ALIAS -tsa http://timestamp.digicert.com 57 | shell: bash 58 | 59 | - name: Upload the taco 60 | uses: actions/upload-artifact@v4 61 | with: 62 | name: clickhouse_jdbc_signed.taco 63 | path: clickhouse-tableau-jdbc/signing_utility/clickhouse_jdbc_signed.taco 64 | if-no-files-found: error 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2016-2023 ClickHouse, Inc. 2 | 3 | Apache License 4 | Version 2.0, January 2004 5 | http://www.apache.org/licenses/ 6 | 7 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 8 | 9 | 1. Definitions. 10 | 11 | "License" shall mean the terms and conditions for use, reproduction, 12 | and distribution as defined by Sections 1 through 9 of this document. 13 | 14 | "Licensor" shall mean the copyright owner or entity authorized by 15 | the copyright owner that is granting the License. 16 | 17 | "Legal Entity" shall mean the union of the acting entity and all 18 | other entities that control, are controlled by, or are under common 19 | control with that entity. For the purposes of this definition, 20 | "control" means (i) the power, direct or indirect, to cause the 21 | direction or management of such entity, whether by contract or 22 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 23 | outstanding shares, or (iii) beneficial ownership of such entity. 24 | 25 | "You" (or "Your") shall mean an individual or Legal Entity 26 | exercising permissions granted by this License. 27 | 28 | "Source" form shall mean the preferred form for making modifications, 29 | including but not limited to software source code, documentation 30 | source, and configuration files. 31 | 32 | "Object" form shall mean any form resulting from mechanical 33 | transformation or translation of a Source form, including but 34 | not limited to compiled object code, generated documentation, 35 | and conversions to other media types. 36 | 37 | "Work" shall mean the work of authorship, whether in Source or 38 | Object form, made available under the License, as indicated by a 39 | copyright notice that is included in or attached to the work 40 | (an example is provided in the Appendix below). 41 | 42 | "Derivative Works" shall mean any work, whether in Source or Object 43 | form, that is based on (or derived from) the Work and for which the 44 | editorial revisions, annotations, elaborations, or other modifications 45 | represent, as a whole, an original work of authorship. For the purposes 46 | of this License, Derivative Works shall not include works that remain 47 | separable from, or merely link (or bind by name) to the interfaces of, 48 | the Work and Derivative Works thereof. 49 | 50 | "Contribution" shall mean any work of authorship, including 51 | the original version of the Work and any modifications or additions 52 | to that Work or Derivative Works thereof, that is intentionally 53 | submitted to Licensor for inclusion in the Work by the copyright owner 54 | or by an individual or Legal Entity authorized to submit on behalf of 55 | the copyright owner. For the purposes of this definition, "submitted" 56 | means any form of electronic, verbal, or written communication sent 57 | to the Licensor or its representatives, including but not limited to 58 | communication on electronic mailing lists, source code control systems, 59 | and issue tracking systems that are managed by, or on behalf of, the 60 | Licensor for the purpose of discussing and improving the Work, but 61 | excluding communication that is conspicuously marked or otherwise 62 | designated in writing by the copyright owner as "Not a Contribution." 63 | 64 | "Contributor" shall mean Licensor and any individual or Legal Entity 65 | on behalf of whom a Contribution has been received by Licensor and 66 | subsequently incorporated within the Work. 67 | 68 | 2. Grant of Copyright License. Subject to the terms and conditions of 69 | this License, each Contributor hereby grants to You a perpetual, 70 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 71 | copyright license to reproduce, prepare Derivative Works of, 72 | publicly display, publicly perform, sublicense, and distribute the 73 | Work and such Derivative Works in Source or Object form. 74 | 75 | 3. Grant of Patent License. Subject to the terms and conditions of 76 | this License, each Contributor hereby grants to You a perpetual, 77 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 78 | (except as stated in this section) patent license to make, have made, 79 | use, offer to sell, sell, import, and otherwise transfer the Work, 80 | where such license applies only to those patent claims licensable 81 | by such Contributor that are necessarily infringed by their 82 | Contribution(s) alone or by combination of their Contribution(s) 83 | with the Work to which such Contribution(s) was submitted. If You 84 | institute patent litigation against any entity (including a 85 | cross-claim or counterclaim in a lawsuit) alleging that the Work 86 | or a Contribution incorporated within the Work constitutes direct 87 | or contributory patent infringement, then any patent licenses 88 | granted to You under this License for that Work shall terminate 89 | as of the date such litigation is filed. 90 | 91 | 4. Redistribution. You may reproduce and distribute copies of the 92 | Work or Derivative Works thereof in any medium, with or without 93 | modifications, and in Source or Object form, provided that You 94 | meet the following conditions: 95 | 96 | (a) You must give any other recipients of the Work or 97 | Derivative Works a copy of this License; and 98 | 99 | (b) You must cause any modified files to carry prominent notices 100 | stating that You changed the files; and 101 | 102 | (c) You must retain, in the Source form of any Derivative Works 103 | that You distribute, all copyright, patent, trademark, and 104 | attribution notices from the Source form of the Work, 105 | excluding those notices that do not pertain to any part of 106 | the Derivative Works; and 107 | 108 | (d) If the Work includes a "NOTICE" text file as part of its 109 | distribution, then any Derivative Works that You distribute must 110 | include a readable copy of the attribution notices contained 111 | within such NOTICE file, excluding those notices that do not 112 | pertain to any part of the Derivative Works, in at least one 113 | of the following places: within a NOTICE text file distributed 114 | as part of the Derivative Works; within the Source form or 115 | documentation, if provided along with the Derivative Works; or, 116 | within a display generated by the Derivative Works, if and 117 | wherever such third-party notices normally appear. The contents 118 | of the NOTICE file are for informational purposes only and 119 | do not modify the License. You may add Your own attribution 120 | notices within Derivative Works that You distribute, alongside 121 | or as an addendum to the NOTICE text from the Work, provided 122 | that such additional attribution notices cannot be construed 123 | as modifying the License. 124 | 125 | You may add Your own copyright statement to Your modifications and 126 | may provide additional or different license terms and conditions 127 | for use, reproduction, or distribution of Your modifications, or 128 | for any such Derivative Works as a whole, provided Your use, 129 | reproduction, and distribution of the Work otherwise complies with 130 | the conditions stated in this License. 131 | 132 | 5. Submission of Contributions. Unless You explicitly state otherwise, 133 | any Contribution intentionally submitted for inclusion in the Work 134 | by You to the Licensor shall be under the terms and conditions of 135 | this License, without any additional terms or conditions. 136 | Notwithstanding the above, nothing herein shall supersede or modify 137 | the terms of any separate license agreement you may have executed 138 | with Licensor regarding such Contributions. 139 | 140 | 6. Trademarks. This License does not grant permission to use the trade 141 | names, trademarks, service marks, or product names of the Licensor, 142 | except as required for reasonable and customary use in describing the 143 | origin of the Work and reproducing the content of the NOTICE file. 144 | 145 | 7. Disclaimer of Warranty. Unless required by applicable law or 146 | agreed to in writing, Licensor provides the Work (and each 147 | Contributor provides its Contributions) on an "AS IS" BASIS, 148 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 149 | implied, including, without limitation, any warranties or conditions 150 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 151 | PARTICULAR PURPOSE. You are solely responsible for determining the 152 | appropriateness of using or redistributing the Work and assume any 153 | risks associated with Your exercise of permissions under this License. 154 | 155 | 8. Limitation of Liability. In no event and under no legal theory, 156 | whether in tort (including negligence), contract, or otherwise, 157 | unless required by applicable law (such as deliberate and grossly 158 | negligent acts) or agreed to in writing, shall any Contributor be 159 | liable to You for damages, including any direct, indirect, special, 160 | incidental, or consequential damages of any character arising as a 161 | result of this License or out of the use or inability to use the 162 | Work (including but not limited to damages for loss of goodwill, 163 | work stoppage, computer failure or malfunction, or any and all 164 | other commercial damages or losses), even if such Contributor 165 | has been advised of the possibility of such damages. 166 | 167 | 9. Accepting Warranty or Additional Liability. While redistributing 168 | the Work or Derivative Works thereof, You may choose to offer, 169 | and charge a fee for, acceptance of support, warranty, indemnity, 170 | or other liability obligations and/or rights consistent with this 171 | License. However, in accepting such obligations, You may act only 172 | on Your own behalf and on Your sole responsibility, not on behalf 173 | of any other Contributor, and only if You agree to indemnify, 174 | defend, and hold each Contributor harmless for any liability 175 | incurred by, or claims asserted against, such Contributor by reason 176 | of your accepting any such warranty or additional liability. 177 | 178 | END OF TERMS AND CONDITIONS 179 | 180 | APPENDIX: How to apply the Apache License to your work. 181 | 182 | To apply the Apache License to your work, attach the following 183 | boilerplate notice, with the fields enclosed by brackets "[]" 184 | replaced with your own identifying information. (Don't include 185 | the brackets!) The text should be enclosed in the appropriate 186 | comment syntax for the file format. We also recommend that a 187 | file or class name and description of purpose be included on the 188 | same "printed page" as the copyright notice for easier 189 | identification within third-party archives. 190 | 191 | Copyright 2016-2023 ClickHouse, Inc. 192 | 193 | Licensed under the Apache License, Version 2.0 (the "License"); 194 | you may not use this file except in compliance with the License. 195 | You may obtain a copy of the License at 196 | 197 | http://www.apache.org/licenses/LICENSE-2.0 198 | 199 | Unless required by applicable law or agreed to in writing, software 200 | distributed under the License is distributed on an "AS IS" BASIS, 201 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 202 | See the License for the specific language governing permissions and 203 | limitations under the License. 204 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ClickHouse Tableau JDBC connector 2 | 3 | ## Intro 4 | 5 | This is an extension for Tableau Desktop / Tableau Server that simplifies the process of connecting Tableau to ClickHouse and extends support for standard Tableau functionality when working with ClickHouse (as compared to Generic ODBC/JDBC) 6 | 7 | ## Features 8 | 9 | - In comparison with **Other Databases (ODBC)**: this connector uses the JDBC driver, which is faster than the ODBC driver in some cases (for example, creating Extracts), and is also much easier to install than ODBC (a cross-platform jar file, which does not require compiling for individual platforms). 10 | - In comparison with **Other Databases (JDBC)**: this connector has fine-tuning SQL queries to implement most of the standard Tableau functionality (including multiple JOINS in the data source, Sets, etc.), and it has a friendly connection dialog ;) 11 | 12 | ## Before you install 13 | 14 | Requirements 15 | - Tableau **2020.4+** 16 | - ClickHouse **20.7+** 17 | 18 | ## Installation (Tableau Desktop) 19 | 1. Download the [Clickhouse JDBC Driver](https://github.com/ClickHouse/clickhouse-java/releases) (version 0.8.X required), and place the `clickhouse-jdbc-0.8.X-shaded-all.jar` to: 20 | - macOS: `~/Library/Tableau/Drivers` 21 | - Windows: `C:\Program Files\Tableau\Drivers` 22 | - You need to create the folder if it doesn't already exist 23 | 2. Download the latest `clickhouse-jdbc.taco` from the [Releases](https://github.com/ClickHouse/clickhouse-tableau-connector-jdbc/releases) page, and place it to: 24 | - macOS: `~/Documents/My Tableau Repository/Connectors` 25 | - Windows: `C:\Users\[Windows User]\Documents\My Tableau Repository\Connectors` 26 | 3. Run Tableau Desktop 27 | 4. In Tableau Desktop: **Connect** ➔ **To a Server** ➔ **ClickHouse JDBC by ClickHouse, Inc.** 28 | 29 | ## Installation (Tableau Prep Builder) 30 | 1. Download the [Clickhouse JDBC Driver](https://github.com/ClickHouse/clickhouse-java/releases) (version 0.8.X required), and place the `clickhouse-jdbc-0.8.X-shaded-all.jar` to: 31 | - macOS: `~/Library/Tableau/Drivers` 32 | - Windows: `C:\Program Files\Tableau\Drivers` 33 | - You need to create the folder if it doesn't already exist 34 | 2. Download the latest `clickhouse-jdbc.taco` from the [Releases](https://github.com/ClickHouse/clickhouse-tableau-connector-jdbc/releases) page and place it to: 35 | - macOS: `~/Documents/My Tableau Prep Repository/Connectors` 36 | - Windows: `C:\Users\[Windows User]\Documents\My Tableau Prep Repository\Connectors` 37 | 3. Run Tableau Prep Builder 38 | 4. In Tableau Prep Builder: **Connections** ➔ **+** ➔ **To a Server** ➔ **ClickHouse JDBC by ClickHouse, Inc.** 39 | 40 | ## Installation (Tableau Server) 41 | 1. Download the [Clickhouse JDBC Driver](https://github.com/ClickHouse/clickhouse-java/releases) (version 0.8.X required), and place the `clickhouse-jdbc-0.8.X-shaded-all.jar` to: 42 | - Linux: `/opt/tableau/tableau_driver/jdbc` 43 | - Windows: `C:\Program Files\Tableau\Drivers` 44 | - You need to create the directory if it doesn't already exist 45 | - *For Linux:* make sure directory is readable by the "tableau" user. To do this: 46 | - Create the directory: 47 | ``` 48 | sudo mkdir -p /opt/tableau/tableau_driver/jdbc 49 | ``` 50 | - Copy the downloaded driver file to the location, replacing `[/path/to/file]` with the path and `[driver file name]` with the name of the driver you downloaded: 51 | ``` 52 | sudo cp [/path/to/file/][driver file name].jar /opt/tableau/tableau_driver/jdbc 53 | ``` 54 | - Set permissions so the file is readable by the "tableau" user, replacing `[driver file name]` with the name of the driver you downloaded: 55 | ``` 56 | sudo chmod 755 /opt/tableau/tableau_driver/jdbc/[driver file name].jar 57 | ``` 58 | 2. Download the latest `clickhouse-jdbc.taco` from the [Releases](https://github.com/ClickHouse/clickhouse-tableau-connector-jdbc/releases) page and place it into these folders on each node: 59 | - Linux: `/opt/tableau/connectors` 60 | - Windows: `C:\Program Files\Tableau\Connectors` 61 | 3. Restart the server. 62 | ``` 63 | tsm restart 64 | ``` 65 | - Note that whenever you add, remove, or update a connector, you need to restart the server to see the changes. 66 | ## Connection tips 67 | ### Initial SQL tab 68 | If the *Set Session ID* checkbox is activated on the Advanced tab (by default), feel free to set session level [settings](https://clickhouse.com/docs/en/operations/settings/settings/) using 69 | ``` 70 | SET my_setting=value; 71 | ``` 72 | ### Advanced tab 73 | In 99% of cases you don't need the Advanced tab, for the remaining 1% you can use the following settings: 74 | - **Custom Connection Parameters**. By default, `socket_timeout` is already specified, this parameter may need to be changed if some extracts are updated for a very long time. The value of this parameter is specified in milliseconds. The rest of the parameters can be found [here](https://github.com/ClickHouse/clickhouse-jdbc/blob/master/clickhouse-client/src/main/java/com/clickhouse/client/config/ClickHouseClientOption.java), add them in this field separated by commas 75 | - **JDBC Driver custom_http_params**. This field allows you to drop some parameters into the ClickHouse connection string by passing values to the [`custom_http_params` parameter of the driver](https://github.com/ClickHouse/clickhouse-jdbc#configuration). For example, this is how `session_id` is specified when the *Set Session ID* checkbox is activated 76 | - **JDBC Driver typeMappings**. This field allows you to [pass a list of ClickHouse data type mappings to Java data types used by the JDBC driver](https://github.com/ClickHouse/clickhouse-jdbc#configuration). The connector automatically displays large Integers as strings thanks to this parameter, you can change this by passing your mapping set *(I do not know why)* using 77 | ``` 78 | UInt256=java.lang.Double,Int256=java.lang.Double 79 | ``` 80 | Read more about mapping in the corresponding section 81 | 82 | - **JDBC Driver URL Parameters**. You can pass the remaining [driver parameters](https://github.com/ClickHouse/clickhouse-jdbc#configuration), for example `jdbcCompliance`, in this field. Be careful, the parameter values must be passed in the URL Encoded format, and in the case of passing `custom_http_params` or `typeMappings` in this field and in the previous fields of the Advanced tab, the values of the preceding two fields on the Advanced tab have a higher priority 83 | - **Set Session ID** checkbox. It is needed to set session-level settings in Initial SQL tab, generates a `session_id` with a timestamp and a pseudo-random number in the format "tableau-jdbc-connector-*{timestamp}*-*{number}*" 84 | ### Limited support for UInt64, Int128, (U)Int256 data types 85 | By default, the driver displays fields of types *UInt64, Int128, (U)Int256* as strings, **but it displays, not converts**. This means that when you try to write the next calculated field, you will get an error 86 | ``` 87 | LEFT([myUInt256], 2) // Error! 88 | ``` 89 | In order to work with large Integer fields as with strings, it is necessary to explicitly wrap the field in the STR() function 90 | ``` 91 | LEFT(STR([myUInt256]), 2) // Works well! 92 | ``` 93 | However, such fields are most often used to find the number of unique values *(IDs as Watch ID, Visit ID in Yandex.Metrika)* or as a *Dimension* to specify the detail of the visualization, it works well. 94 | ``` 95 | COUNTD([myUInt256]) // Works well too! 96 | ``` 97 | When using the data preview (View data) of a table with UInt64 fields, an error does not appear now. 98 | ## Analysis tips 99 | ### MEDIAN() and PERCENTILE() functions 100 | - In Live mode the MEDIAN() and PERCENTILE() functions (since connector v0.1.3 release) use the [ClickHouse quantile()() function](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/quantile/), which significantly speeds up the calculation, but uses sampling. If you want to get accurate calculation results, then use functions `MEDIAN_EXACT()` and `PERCENTILE_EXACT()` (based on [quantileExact()()](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/quantileexact/)). 101 | - In Extract mode you can't use MEDIAN_EXACT() and PERCENTILE_EXACT() because MEDIAN() and PERCENTILE() are always accurate (and slow). 102 | ### Additional functions for Calculated Fields in Live mode 103 | ClickHouse has a huge number of functions that can be used for data analysis — much more than Tableau supports. For the convenience of users, we have added new functions that are available for use in Live mode when creating Calculated Fields. Unfortunately, it is not possible to add descriptions to these functions in the Tableau interface, so we will add a description for them right here. 104 | - **[`-If` Aggregation Combinator](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/combinators/#-if)** *(added in v0.2.3)* - allows to have Row-Level Filters right in the Aggregate Calculation. `SUM_IF(), AVG_IF(), COUNT_IF(), MIN_IF() & MAX_IF()` functions have been added. 105 | - **`BAR([my_int], [min_val_int], [max_val_int], [bar_string_length_int])`** *(added in v0.2.1)* — Forget about boring bar charts! Use `BAR()` function instead (equivalent of [`bar()`](https://clickhouse.com/docs/en/sql-reference/functions/other-functions/#function-bar) in ClickHouse). For example, this calculated field returns nice bars as String: 106 | ``` 107 | BAR([my_int], [min_val_int], [max_val_int], [bar_string_length_int]) + " " + FORMAT_READABLE_QUANTITY([my_int]) 108 | ``` 109 | ``` 110 | == BAR() == 111 | ██████████████████▊ 327.06 million 112 | █████ 88.02 million 113 | ███████████████ 259.37 million 114 | ``` 115 | - **`COUNTD_UNIQ([my_field])`** *(added in v0.2.0)* — Calculates the approximate number of different values of the argument. Equivalent of [uniq()](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/uniq/). Much faster than COUNTD(). 116 | - **`DATE_BIN('day', 10, [my_datetime_or_date])`** *(added in v0.2.1)* — equivalent of [`toStartOfInterval()`](https://clickhouse.com/docs/en/sql-reference/functions/date-time-functions/#tostartofintervaltime-or-data-interval-x-unit-time-zone) in ClickHouse. Rounds down a Date or Date & Time to the given interval, for example: 117 | ``` 118 | == my_datetime_or_date == | == DATE_BIN('day', 10, [my_datetime_or_date]) == 119 | 28.07.2004 06:54:50 | 21.07.2004 00:00:00 120 | 17.07.2004 14:01:56 | 11.07.2004 00:00:00 121 | 14.07.2004 07:43:00 | 11.07.2004 00:00:00 122 | ``` 123 | - **`FORMAT_READABLE_QUANTITY([my_integer])`** *(added in v0.2.1)* — Returns a rounded number with a suffix (thousand, million, billion, etc.) as a string. It is useful for reading big numbers by human. Equivalent of [`formatReadableQuantity()`](https://clickhouse.com/docs/en/sql-reference/functions/other-functions/#formatreadablequantityx). 124 | - **`FORMAT_READABLE_TIMEDELTA([my_integer_timedelta_sec], [optional_max_unit])`** *(added in v0.2.1)* — Accepts the time delta in seconds. Returns a time delta with (year, month, day, hour, minute, second) as a string. `optional_max_unit` is maximum unit to show. Acceptable values: `seconds`, `minutes`, `hours`, `days`, `months`, `years`. Equivalent of [`formatReadableTimeDelta()`](https://clickhouse.com/docs/en/sql-reference/functions/other-functions/#formatreadabletimedelta). 125 | - **`GET_SETTING([my_setting_name])`** *(added in v0.2.1)* — Returns the current value of a custom setting. Equivalent of [`getSetting()`](https://clickhouse.com/docs/en/sql-reference/functions/other-functions/#getSetting). 126 | - **`HEX([my_string])`** *(added in v0.2.1)* — Returns a string containing the argument’s hexadecimal representation. Equivalent of [`hex()`](https://clickhouse.com/docs/en/sql-reference/functions/encoding-functions/#hex). 127 | - **`KURTOSIS([my_number])`** — Computes the sample kurtosis of a sequence. Equivalent of [`kurtSamp()`](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/kurtsamp/#kurtsamp). 128 | - **`KURTOSISP([my_number])`** — Computes the kurtosis of a sequence. The equivalent of [`kurtPop()`](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/kurtpop/#kurtpop). 129 | - **`MEDIAN_EXACT([my_number])`** *(added in v0.1.3)* — Exactly computes the median of a numeric data sequence. Equivalent of [`quantileExact(0.5)(...)`](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/quantileexact/#quantileexact). 130 | - **`MOD([my_number_1], [my_number_2])`** — Calculates the remainder after division. If arguments are floating-point numbers, they are pre-converted to integers by dropping the decimal portion. Equivalent of [`modulo()`](https://clickhouse.com/docs/en/sql-reference/functions/arithmetic-functions/#modulo). 131 | - **`PERCENTILE_EXACT([my_number], [level_float])`** *(added in v0.1.3)* — Exactly computes the percentile of a numeric data sequence. The recommended level range is [0.01, 0.99]. Equivalent of [`quantileExact()()`](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/quantileexact/#quantileexact). 132 | - **`PROPER([my_string])`** *(added in v0.2.5)* - Converts a text string so the first letter of each word is capitalized and the remaining letters are in lowercase. Spaces and non-alphanumeric characters such as punctuation also act as separators. For example: 133 | ``` 134 | PROPER("PRODUCT name") => "Product Name" 135 | ``` 136 | ``` 137 | PROPER("darcy-mae") => "Darcy-Mae" 138 | ``` 139 | - **`RAND()`** *(added in v0.2.1)* — returns integer (UInt32) number, for example `3446222955`. Equivalent of [`rand()`](https://clickhouse.com/docs/en/sql-reference/functions/random-functions/#rand). 140 | - **`RANDOM()`** *(added in v0.2.1)* — unofficial [`RANDOM()`](https://kb.tableau.com/articles/issue/random-function-produces-inconsistent-results) Tableau function, which returns float between 0 and 1. 141 | - **`RAND_CONSTANT([optional_field])`** *(added in v0.2.1)* — Produces a constant column with a random value. Something like `{RAND()}` Fixed LOD, but faster. Equivalent of [`randConstant()`](https://clickhouse.com/docs/en/sql-reference/functions/random-functions/#randconstant). 142 | - **`REAL([my_number])`** — Casts field to float (Float64). Details [`here`](https://clickhouse.com/docs/en/sql-reference/data-types/decimal/#operations-and-result-type). 143 | - **`SHA256([my_string])`** *(added in v0.2.1)* — Calculates SHA-256 hash from a string and returns the resulting set of bytes as a string (FixedString). Convenient to use with the `HEX()` function, for example, `HEX(SHA256([my_string]))`. Equivalent of [`SHA256()`](https://clickhouse.com/docs/en/sql-reference/functions/hash-functions/#sha). 144 | - **`SKEWNESS([my_number])`** — Computes the sample skewness of a sequence. Equivalent of [`skewSamp()`](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/skewsamp/#skewsamp). 145 | - **`SKEWNESSP([my_number])`** — Computes the skewness of a sequence. Equivalent of [`skewPop()`](https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/skewpop/#skewpop). 146 | - **`TO_TYPE_NAME([field])`** *(added in v0.2.1)* — Returns a string containing the ClickHouse type name of the passed argument. Equivalent of [`toTypeName()`](https://clickhouse.com/docs/en/sql-reference/functions/other-functions/#totypenamex). 147 | - **`TRUNC([my_float])`** — It is the same as the `FLOOR([my_float])` function. Equivalent of [`trunc()`](https://clickhouse.com/docs/en/sql-reference/functions/rounding-functions/#truncx-n-truncatex-n). 148 | - **`UNHEX([my_string])`** *(added in v0.2.1)* — Performs the opposite operation of `HEX()`. Equivalent of [`unhex()`](https://clickhouse.com/docs/en/sql-reference/functions/encoding-functions/#unhexstr). 149 | 150 | ## Future plans 151 | - Publishing the connector at [exchange.tableau.com](https://exchange.tableau.com/connectors) 152 | 153 | ## Tests 154 | The connector is being tested with the [TDVT framework](https://tableau.github.io/connector-plugin-sdk/docs/tdvt) and currently maintains a 97% coverage ratio. 155 | 156 | ## Acknowledgement 157 | 158 | Originally developed by [ANALYTIKA PLUS](https://analytikaplus.ru?utm_source=github&utm_medium=repo&utm_campaign=tableau_clickhouse_connector) 159 | -------------------------------------------------------------------------------- /clickhouse_jdbc/Readme.md: -------------------------------------------------------------------------------- 1 | ClickHouse Tableau JDBC Connector. -------------------------------------------------------------------------------- /clickhouse_jdbc/connection-fields.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /clickhouse_jdbc/connection-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /clickhouse_jdbc/connectionBuilder.js: -------------------------------------------------------------------------------- 1 | (function dsbuilder(attr) { 2 | // setting custom HTTP parameterss 3 | var customHttpParams = {}; 4 | 5 | // fix IN/OUT Top-N Sets 6 | customHttpParams['join_use_nulls'] = 1; 7 | 8 | // parsing custom_http_params 9 | if(attr['v-custom-http-params'] && attr['v-custom-http-params'].length > 0){ 10 | var customParams = attr['v-custom-http-params'].split(','); 11 | for(var i = 0; i < customParams.length; i++){ 12 | var param = customParams[i].split('='); 13 | customHttpParams[param[0]] = param[1]; 14 | } 15 | } 16 | 17 | // setting session_id 18 | if(attr['v-set-session-id'] == "true"){ 19 | customHttpParams['session_id'] = "tableau-jdbc-connector-" + Date.now() + "-" + Math.floor(Math.random() * (Math.floor(10000000) - Math.ceil(1) + 1)) + Math.ceil(1); 20 | } 21 | 22 | var customHttpParamsArr = []; 23 | for (var key in customHttpParams){ 24 | customHttpParamsArr.push(key + "=" + customHttpParams[key]); 25 | } 26 | 27 | // preparing customUrlParams 28 | var customUrlParams = {}; 29 | 30 | if(attr['v-custom-url-params'] && attr['v-custom-url-params'].length > 0){ 31 | var customParams = attr['v-custom-url-params'].split(','); 32 | for(var i = 0; i < customParams.length; i++){ 33 | var param = customParams[i].split('='); 34 | customUrlParams[param[0]] = param[1]; 35 | } 36 | } 37 | 38 | // default type mappings 39 | typeMappings = {'UInt64': 'java.lang.String', 40 | 'UInt128': 'java.lang.String', 41 | 'Int128': 'java.lang.String', 42 | 'UInt256': 'java.lang.String', 43 | 'Int256': 'java.lang.String'}; 44 | 45 | // setting custom type mappings 46 | if(attr['v-custom-type-mappings'] && attr['v-custom-type-mappings'].length > 0){ 47 | var customTypeMappings = attr['v-custom-type-mappings'].split(','); 48 | for(var i in customTypeMappings){ 49 | var customTypeMapping = customTypeMappings[i].split('='); 50 | typeMappings[customTypeMapping[0]] = customTypeMapping[1]; 51 | } 52 | } 53 | 54 | var typeMappingsArr = []; 55 | for (var key in typeMappings){ 56 | typeMappingsArr.push(key + "=" + typeMappings[key]); 57 | } 58 | 59 | // updating some URL params 60 | customUrlParams['custom_http_params'] = customHttpParamsArr.join(','); 61 | customUrlParams['typeMappings'] = typeMappingsArr.join(','); 62 | 63 | // building encoded URL params string 64 | var customUrlParamsArr = []; 65 | for (var key in customUrlParams){ 66 | customUrlParamsArr.push(key + "=" + encodeURIComponent(customUrlParams[key])); 67 | } 68 | 69 | var customUrlParamsString = customUrlParamsArr.join('&'); 70 | 71 | // building full URL string 72 | var urlBuilder = "jdbc:clickhouse://" + attr['server'] + ":" + attr['port'] 73 | + "/?" + customUrlParamsString; 74 | return [urlBuilder]; 75 | }) -------------------------------------------------------------------------------- /clickhouse_jdbc/connectionProperties.js: -------------------------------------------------------------------------------- 1 | (function propertiesbuilder(attr) { 2 | var props = {}; 3 | 4 | // setting custom Connection Parameters 5 | if(attr["v-custom-connection-params"] && attr["v-custom-connection-params"].length > 0){ 6 | var customParams = attr["v-custom-connection-params"].split(','); 7 | for(var i = 0; i < customParams.length; i++){ 8 | var param = customParams[i].split('='); 9 | props[param[0]] = param[1]; 10 | } 11 | } 12 | 13 | props["user"] = attr["username"]; 14 | props["password"] = attr["password"]; 15 | 16 | if (attr["sslmode"] == "require") { 17 | props["ssl"] = "true"; 18 | props["sslmode"] = "STRICT"; 19 | } 20 | 21 | return props; 22 | }) -------------------------------------------------------------------------------- /clickhouse_jdbc/connectionResolver.tdr: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |