Giter VIP home page Giter VIP logo

clickhouse-odbc's Introduction

ODBC Driver for ClickHouse

Build and Test - Linux Build and Test - macOS Build and Test - Windows

Introduction

This is the official ODBC driver implementation for accessing ClickHouse as a data source.

For more information on ClickHouse go to ClickHouse home page.

For more information on what ODBC is go to ODBC Overview.

The canonical repo for this driver is located at https://github.com/ClickHouse/clickhouse-odbc.

See LICENSE file for licensing information.

Table of contents

Installation

Pre-built binary packages of the release versions of the driver available for the most common platforms at:

The ODBC driver is mainly tested against ClickHouse server version 21.3. Older versions of ClickHouse server as well as newer ones (with greater success) should work too. Possible complications with older version may include handling Null values and Nullable types, alternative wire protocol support, timezone handling during date/time conversions, etc.

Note, that since ODBC drivers are not used directly by a user, but rather accessed through applications, which in their turn access the driver through ODBC driver manager, user have to install the driver for the same architecture (32- or 64-bit) as the application that is going to access the driver. Moreover, both the driver and the application must be compiled for (and actually use during run-time) the same ODBC driver manager implementation (we call them "ODBC providers" here). There are three supported ODBC providers:

  • ODBC driver manager associated with MDAC (Microsoft Data Access Components, sometimes referenced as WDAC, Windows Data Access Components) - the standard ODBC provider of Windows
  • UnixODBC - the most common ODBC provider in Unix-like systems. Theoretically, could be used in Cygwin or MSYS/MinGW environments in Windows too.
  • iODBC - less common ODBC provider, mainly used in Unix-like systems, however, it is the standard ODBC provider in macOS. Theoretically, could be used in Cygwin or MSYS/MinGW environments in Windows too.

If you have Homebrew installed (usually applicable to macOS only, but can also be available in Linux), just execute:

brew install clickhouse-odbc

If you don't see a package that matches your platforms under Releases, or the version of your system is significantly different than those of the available packages, or maybe you want to try a bleeding edge version of the code that hasn't been released yet, you can always build the driver manually from sources:

Note, that it is always a good idea to install the driver from the corresponding native package (if one is supported for your platform, like .msi, etc., which you can also easily create if you are building from sources), than use the binaries that were manually copied to a destination folder.

Native packages will have all the dependency information so when you install the driver using a native package, all required run-time packages will be installed automatically. If you use manual packaging, i.e., just extract driver binaries to some folder, you also have to make sure that all the run-time dependencies are satisfied in your system manually:

Configuration

The first step usually consists of registering the driver so that the corresponding ODBC provider is able to locate it.

The next step is defining one or more DSNs, associated with the newly registered driver, and setting driver-specific parameters in the body of those DSN definitions.

All this involves modifying a dedicated registry keys in case of MDAC, or editing odbcinst.ini (for driver registration) and odbc.ini (for DSN definition) files for UnixODBC or iODBC, directly or indirectly.

This will be performed automatically using some default values if you are installing the driver using native installers.

Otherwise, if you are configuring manually, or need to modify the default configuration created by the installer, please see the exact locations of files (or registry keys) that need to be modified in the corresponding section below:

The list of DSN parameters recognized by the driver is as follows:

Parameter Default value Description
Url empty URL that points to a running ClickHouse instance, may include username, password, port, database, etc. Also, see URL query string
Proto deduced from Url, or from Port and SSLMode: https if 443 or 8443 or SSLMode is not empty, http otherwise Protocol, one of: http, https
Server or Host deduced from Url IP or hostname of a server with a running ClickHouse instance on it
Port deduced from Url, or from Proto: 8443 if https, 8123 otherwise Port on which the ClickHouse instance is listening
Path /query Path portion of the URL
UID or Username default User name
PWD or Password empty Password
Database default Database name to connect to
Timeout 30 Connection timeout
VerifyConnectionEarly off Verify the connection and credentials during SQLConnect and similar calls (adds a typical overhead of one trivial remote query execution), otherwise, possible connection-related failures will be detected later, during SQLExecute and similar calls
SSLMode empty Certificate verification method (used by TLS/SSL connections, ignored in Windows), one of: allow, prefer, require, use allow to enable SSL_VERIFY_PEER TLS/SSL certificate verification mode, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT is used otherwise
PrivateKeyFile empty Path to private key file (used by TLS/SSL connections), can be empty if no private key file is used
CertificateFile empty Path to certificate file (used by TLS/SSL connections, ignored in Windows), if the private key and the certificate are stored in the same file, this can be empty if PrivateKeyFile is specified
CALocation empty Path to the file or directory containing the CA/root certificates (used by TLS/SSL connections, ignored in Windows)
HugeIntAsString off Report integer column types that may underflow or overflow 64-bit signed integer (SQL_BIGINT) as a String/SQL_VARCHAR
DriverLog on if CMAKE_BUILD_TYPE is Debug, off otherwise Enable or disable the extended driver logging
DriverLogFile \temp\clickhouse-odbc-driver.log on Windows, /tmp/clickhouse-odbc-driver.log otherwise Path to the extended driver log file (used when DriverLog is on)

URL query string

Some of configuration parameters can be passed to the server as a part of the query string of the URL.

The list of parameters in the query string of the URL that are also recognized by the driver is as follows:

Parameter Default value Description
database default Database name to connect to
default_format ODBCDriver2 Default wire format of the resulting data that the server will send to the driver. Formats supported by the driver are: ODBCDriver2 and RowBinaryWithNamesAndTypes

Note, that currently there is a difference in timezone handling between ODBCDriver2 and RowBinaryWithNamesAndTypes formats: in ODBCDriver2 date and time values are presented to the ODBC application in server's timezone, wherease in RowBinaryWithNamesAndTypes they are converted to local timezone. This behavior will be changed/parametrized in future. If server and ODBC application timezones are the same, date and time values handling will effectively be identical between these two formats.

Troubleshooting: driver manager tracing and driver logging

To debug issues with the driver, first things that need to be done are:

Building from sources

The general requirements for building the driver from sources are as follows:

  • CMake 3.13.5 and later
  • C++17 and C11 capable compiler toolchain:
    • Clang 4 and later
    • GCC 7 and later
    • Xcode 10 and later (on macOS 10.14 and later)
    • Microsoft Visual Studio 2017 and later

Additional requirements exist for each platform, which also depend on whether packaging and/or testing is performed.

See the exact steps for each platform in the corresponding section below:

The list of configuration options recognized during the CMake generation step is as follows:

Option Default value Description
CMAKE_BUILD_TYPE RelWithDebInfo Build type, one of: Debug, Release, RelWithDebInfo
CH_ODBC_ALLOW_UNSAFE_DISPATCH ON Allow unchecked handle dispatching (may slightly increase performance in some scenarios)
CH_ODBC_ENABLE_SSL ON Enable TLS/SSL (required for utilizing https:// interface, etc.)
CH_ODBC_ENABLE_INSTALL ON Enable install targets (required for packaging)
CH_ODBC_ENABLE_TESTING inherits value of BUILD_TESTING Enable test targets
CH_ODBC_PREFER_BUNDLED_THIRD_PARTIES ON Prefer bundled over system variants of third party libraries
CH_ODBC_PREFER_BUNDLED_POCO inherits value of CH_ODBC_PREFER_BUNDLED_THIRD_PARTIES Prefer bundled over system variants of Poco library
CH_ODBC_PREFER_BUNDLED_SSL inherits value of CH_ODBC_PREFER_BUNDLED_POCO Prefer bundled over system variants of TLS/SSL library
CH_ODBC_PREFER_BUNDLED_GOOGLETEST inherits value of CH_ODBC_PREFER_BUNDLED_THIRD_PARTIES Prefer bundled over system variants of Google Test library
CH_ODBC_PREFER_BUNDLED_NANODBC inherits value of CH_ODBC_PREFER_BUNDLED_THIRD_PARTIES Prefer bundled over system variants of nanodbc library
CH_ODBC_RUNTIME_LINK_STATIC OFF Link with compiler and language runtime statically
CH_ODBC_THIRD_PARTY_LINK_STATIC ON Link with third party libraries statically
CH_ODBC_DEFAULT_DSN_ANSI ClickHouse DSN (ANSI) Default ANSI DSN name
CH_ODBC_DEFAULT_DSN_UNICODE ClickHouse DSN (Unicode) Default Unicode DSN name
TEST_DSN_LIST ${CH_ODBC_DEFAULT_DSN_ANSI};${CH_ODBC_DEFAULT_DSN_UNICODE} ;-separated list of DSNs, each test will be executed with each of these DSNs

Configuration options above can be specified in the first cmake command (generation step) in a form of -Dopt=val.

Appendices

Run-time dependencies: Windows

All modern Windows systems come with preinstalled MDAC driver manager.

Another run-time dependecies are C++ Redistributable for Visual Studio 2017 or same for 2019, etc., depending on the package being installed, however the required DLL's are redistributed with the .msi installer, and you can choose to install them from there, if you don't have them installed in your system already.

Run-time dependencies: macOS

iODBC

Execute the following in the terminal (assuming you have Homebrew installed):

brew update
brew install poco openssl icu4c libiodbc

UnixODBC

Execute the following in the terminal (assuming you have Homebrew installed):

brew update
brew install poco openssl icu4c unixodbc

Run-time dependencies: Red Hat/CentOS

UnixODBC

Execute the following in the terminal:

sudo yum install openssl libicu unixODBC

iODBC

Execute the following in the terminal:

sudo yum install openssl libicu libiodbc

Run-time dependencies: Debian/Ubuntu

UnixODBC

Execute the following in the terminal:

sudo apt install openssl libicu unixodbc

iODBC

Execute the following in the terminal:

sudo apt install openssl libicu libiodbc2

Configuration: MDAC/WDAC (Microsoft/Windows Data Access Components)

To configure already installed drivers and DSNs, or create new DSNs, use Microsoft ODBC Data Source Administrator tool:

  • for 32-bit applications (and drivers) execute %systemdrive%\Windows\SysWoW64\Odbcad32.exe
  • for 64-bit applications (and drivers) execute %systemdrive%\Windows\System32\Odbcad32.exe

For full description of ODBC configuration mechanism in Windows, as well as for the case when you want to learn how to manually register a driver and have a full control on configuration in general, see:

Note, that the keys are subject to "Registry Redirection" mechanism, with caveats.

You can find sample configuration for this driver here (just map the keys to corresponding sections in registry):

Configuration: UnixODBC

In short, usually you will end up editing /etc/odbcinst.ini and /etc/odbc.ini for system-wide driver and DSN entries, and ~/.odbcinst.ini and ~/.odbc.ini for user-wide driver and DSN entries.

There can be exceptions to this, as these paths are configurable during the compilation of UnixODBC itself, or during the run-time via ODBCINI, ODBCINSTINI, and ODBCSYSINI.

For more info, see:

You can find sample configuration for this driver here:

These samples can be added to the corresponding configuration files using the odbcinst tool (assuming the package is installed under /usr/local):

odbcinst -i -d -f /usr/local/share/doc/clickhouse-odbc/config/odbcinst.ini.sample
odbcinst -i -s -l -f /usr/local/share/doc/clickhouse-odbc/config/odbc.ini.sample

Configuration: iODBC

In short, usually you will end up editing /etc/odbcinst.ini and /etc/odbc.ini for system-wide driver and DSN entries, and ~/.odbcinst.ini and ~/.odbc.ini for user-wide driver and DSN entries.

In macOS, if those INI files exist, they usually are symbolic or hard links to /Library/ODBC/odbcinst.ini and /Library/ODBC/odbc.ini for system-wide, and ~/Library/ODBC/odbcinst.ini and ~/Library/ODBC/odbc.ini for user-wide configs respectively.

There can be exceptions to this, as these paths are configurable during the compilation of iODBC itself, or during the run-time via ODBCINI and ODBCINSTINI. Note, that ODBCINSTINI in iODBC contains the full path to the file, while for UnixODBC it is a file name, and the file itself is expected to be under ODBCSYSINI dir.

For more info, see:

You can find sample configuration for this driver here:

Enabling driver manager tracing: MDAC/WDAC (Microsoft/Windows Data Access Components)

Comprehensive explanations (possibly, with some irrelevant vendor-specific details though) on how to enable ODBC driver manager tracing could be found at the following links:

Enabling driver manager tracing: UnixODBC

Comprehensive explanations (possibly, with some irrelevant vendor-specific details though) on how to enable ODBC driver manager tracing could be found at the following links:

Enabling driver manager tracing: iODBC

Comprehensive explanations (possibly, with some irrelevant vendor-specific details though) on how to enable ODBC driver manager tracing could be found at the following links:

Building from sources: Windows

Build-time dependencies

CMake bundled with the recent versions of Visual Studio can be used.

An SDK required for building the ODBC driver is included in Windows SDK, which in its turn is also bundled with Visual Studio.

You will need to install WiX toolset to be able to generate .msi packages. You can download and install it from WiX toolset home page.

Build steps

All of the following commands have to be issued in Visual Studio Command Prompt:

  • use x86 Native Tools Command Prompt for VS 2019 or equivalent for 32-bit builds
  • use x64 Native Tools Command Prompt for VS 2019 or equivalent for 64-bit builds

Clone the repo with submodules:

git clone --recursive [email protected]:ClickHouse/clickhouse-odbc.git

Enter the cloned source tree, create a temporary build folder, and generate the solution and project files in it:

cd clickhouse-odbc
mkdir build
cd build

# Configuration options for the project can be specified in the next command in a form of '-Dopt=val'

# Use the following command for 32-bit build only.
cmake -A Win32 -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

# Use the following command for 64-bit build only.
cmake -A x64 -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

Build the generated solution in-place:

cmake --build . --config RelWithDebInfo
cmake --build . --config RelWithDebInfo --target package

...and, optionally, run tests (note, that for non-unit tests, preconfigured driver and DSN entries must exist, that point to the binaries generated in this build folder):

cmake --build . --config RelWithDebInfo --target test

...or open the IDE and build all, package, and test targets manually from there:

cmake --open .

Building from sources: macOS

Build-time dependencies

You will need macOS 10.14 or later, Xcode 10 or later with Command Line Tools installed, as well as up-to-date Homebrew available in the system.

Install Homebrew using the following command, and follow the printed instructions on any additional steps required to complete the installation:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then, install the latest Xcode from App Store. Open it at least once to accept the end-user license agreement and automatically install the required components.

Then, make sure that the latest Command Line Tools are installed and selected in the system:

sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

Reboot.

Build-time dependencies: iODBC

Execute the following in the terminal:

brew update
brew install git cmake make poco openssl icu4c libiodbc

Build-time dependencies: UnixODBC

Execute the following in the terminal:

brew update
brew install git cmake make poco openssl icu4c unixodbc

Build steps

Clone the repo recursively with submodules:

git clone --recursive [email protected]:ClickHouse/clickhouse-odbc.git

Enter the cloned source tree, create a temporary build folder, and generate a Makefile for the project in it:

cd clickhouse-odbc
mkdir build
cd build

# Configuration options for the project can be specified in the next command in a form of '-Dopt=val'.

# You may also add '-G Xcode' to the next command, in order to use Xcode as a build system or IDE, and generate the solution and project files instead of Makefile.
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENSSL_ROOT_DIR=$(brew --prefix)/opt/openssl -DICU_ROOT=$(brew --prefix)/opt/icu4c ..

Build the generated solution in-place:

cmake --build . --config RelWithDebInfo
cmake --build . --config RelWithDebInfo --target package

...and, optionally, run tests (note, that for non-unit tests, preconfigured driver and DSN entries must exist, that point to the binaries generated in this build folder):

cmake --build . --config RelWithDebInfo --target run_tests

...or, if you configured the project with '-G Xcode' initially, open the IDE and build all, package, and run_tests targets manually from there:

cmake --open .

Building from sources: Red Hat/CentOS

Build-time dependencies: UnixODBC

Execute the following in the terminal:

sudo yum install epel-release
sudo yum groupinstall "Development Tools"
sudo yum install centos-release-scl
sudo yum install devtoolset-8
sudo yum install git cmake3 rpm-build openssl-devel libicu-devel unixODBC-devel

Build-time dependencies: iODBC

Execute the following in the terminal:

sudo yum install epel-release
sudo yum groupinstall "Development Tools"
sudo yum install centos-release-scl
sudo yum install devtoolset-8
sudo yum install git cmake3 rpm-build openssl-devel libicu-devel libiodbc-devel

Build steps

All of the following commands have to be issued right after this one command issued in the same terminal session:

scl enable devtoolset-8 -- bash

Clone the repo with submodules:

git clone --recursive [email protected]:ClickHouse/clickhouse-odbc.git

Enter the cloned source tree, create a temporary build folder, and generate a Makefile for the project in it:

cd clickhouse-odbc
mkdir build
cd build

# Configuration options for the project can be specified in the next command in a form of '-Dopt=val'

cmake3 -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

Build the generated solution in-place:

cmake3 --build . --config RelWithDebInfo
cmake3 --build . --config RelWithDebInfo --target package

...and, optionally, run tests (note, that for non-unit tests, preconfigured driver and DSN entries must exist, that point to the binaries generated in this build folder):

cmake3 --build . --config RelWithDebInfo --target test

Building from sources: Debian/Ubuntu

Build-time dependencies: UnixODBC

Execute the following in the terminal:

sudo apt install build-essential git cmake libpoco-dev libssl-dev libicu-dev unixodbc-dev

Build-time dependencies: iODBC

Execute the following in the terminal:

sudo apt install build-essential git cmake libpoco-dev libssl-dev libicu-dev libiodbc2-dev

Build steps

Assuming, that the system cc and c++ are pointing to the compilers that satisfy the minimum requirements from Building from sources.

If the version of cmake is not recent enough, you can install a newer version by folowing instructions from one of these pages:

Clone the repo with submodules:

git clone --recursive [email protected]:ClickHouse/clickhouse-odbc.git

Enter the cloned source tree, create a temporary build folder, and generate a Makefile for the project in it:

cd clickhouse-odbc
mkdir build
cd build

# Configuration options for the project can be specified in the next command in a form of '-Dopt=val'

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

Build the generated solution in-place:

cmake --build . --config RelWithDebInfo
cmake --build . --config RelWithDebInfo --target package

...and, optionally, run tests (note, that for non-unit tests, preconfigured driver and DSN entries must exist, that point to the binaries generated in this build folder):

cmake --build . --config RelWithDebInfo --target test

clickhouse-odbc's People

Contributors

alexander-chashnikov avatar alexey-milovidov avatar artpaul avatar avasiliev avatar blazerer avatar blinkov avatar chipitsine avatar deem0n avatar dimaskovas avatar dmserg avatar egatov avatar enmk avatar f1yegor avatar filimonov avatar minimajack avatar mmauri avatar pkartaviy avatar proller avatar shikhragimov avatar sunsingerus avatar traceon avatar vzakaznikov avatar xhochy avatar zlobober avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clickhouse-odbc's Issues

Connect Power BI problems

Hi all,

Thanks for providing this odbc driver.
We have build this driver successfully in windows and tried to use Power BI to connect clickhouse odbc. When trying to load the table to Power BI using direct query mode, we have met the error:

"we can not convert the value null to type table"

While our table have no null values.

I have found that the dremio odbc driver may have the same problem and they have fixed it.
https://community.dremio.com/t/cannot-convert-the-value-null-to-type-table/679

So if it is possible that this clickhouse odbc driver have something incompatible with Power BI?

Thanks.
Wenjing

Как скомпилировать под 32 bit

Собственно вопрос, как скомпилировать драйвер под 32битную платформу? Интересует linux Ubuntu 16. В коде проекта в файле arch.cmake нашел проверку такого флага "CMAKE_LIBRARY_ARCHITECTURE", там же кстати предупреждение, что 32бита поддерживается экспериментально, и указал флаг для cmake, но похоже что в генерации ничего не поменялось
Собственно вопрос, как скомпилировать драйвер под 32битную платформу? Интересует linux Ubuntu 16. В коде проекта в файле arch.cmake нашел проверку такого флага "CMAKE_LIBRARY_ARCHITECTURE", там же кстати предупреждение, что 32бита поддерживается экспериментально, и указал флаг для cmake, но похоже что в генерации ничего не поменялось
sega@sega-VirtualBox:~/src/ODBC/clickhouse-odbc/build$ cmake .. -DCMAKE_LIBRARY_ARCHITECTURE="i386"

-- Using ltdl: /usr/lib/x86_64-linux-gnu/libltdl.a
-- Using Poco:  : PocoFoundation,PocoUtil,PocoNet
-- Using odbc: /usr/include : /usr/lib/x86_64-linux-gnu/libodbc.a
-- Building for: Linux-4.13.0-36-generic x86_64 x86_64-linux-gnu ; CCACHE=CCACHE_FOUND-NOTFOUND 
-- Linux x86_64 Linux-4.13.0-36-generic 4.13.0-36-generic
-- Poco package version: 1.8.2
-- Checking for C++11 compiler
-- Checking for C++11 compiler - available
-- Checking for C++14 compiler
-- Checking for C++14 compiler - available
-- Setting Poco build type - RELWITHDEBINFO
-- Building static libraries
-- Building without tests & samples
-- Build with using internal copy of sqlite, libz, pcre, expat, ...
-- Platform has THREE PARAM at PTHREAD_SETAFFINITY_NP
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing:  OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR) 
-- CMake 3.5.1 successfully configured Poco using Unix Makefiles generator
-- Installation target path: /usr/local
-- C_FLAGS:  =
-- CMAKE_C_FLAGS_DEBUG:=-g   -D_DEBUG
-- CMAKE_C_FLAGS_RELEASE:=-O3 -DNDEBUG
-- CMAKE_C_FLAGS_MINSIZEREL:=-Os -DNDEBUG
-- CMAKE_C_FLAGS_RELWITHDEBINFO:=-O2 -g -DNDEBUG
-- 
-- 
-- CXX_FLAGS:= -O2 -g -fvisibility-inlines-hidden
-- CMAKE_CXX_FLAGS_DEBUG:=-g -D_DEBUG
-- CMAKE_CXX_FLAGS_RELEASE:=-O3 -DNDEBUG
-- CMAKE_CXX_FLAGS_MINSIZEREL:=-Os -DNDEBUG
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO:=-O2 -g -DNDEBUG
-- Building: Net
-- compiler C   = /usr/bin/cc  -O2 -g -DNDEBUG
-- compiler CXX = /usr/bin/c++  -O2 -g -fvisibility-inlines-hidden -O2 -g -DNDEBUG
-- LINKER_FLAGS =  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sega/src/ODBC/clickhouse-odbc/build

Unable to build ODBC-driver on Ubuntu

Hi guys!

Got the following error:

user@ubuntu:~/clickhouse-odbc$ mkdir -p build; cd build && cmake .. && make -j $(nproc || sysctl -n hw.ncpu || echo 2)
-- CMAKE_BUILD_TYPE:
-- Using Poco: /home/user/clickhouse-odbc/contrib/poco/Foundation/include/;/home/user/clickhouse-odbc/contrib/poco/Util/include/;/home/user/clickhouse-odbc/contrib/poco/Net/include/ : PocoFoundation,PocoUtil,PocoNet
CMake Error at CMakeLists.txt:63 (include):
  include could not find load file:

    contrib/poco/cmake/FindODBC.cmake


CMake Error at cmake/Modules/CheckODBCversion.cmake:15 (MESSAGE):
  unixodbc >= 2.3.0 required.
Call Stack (most recent call first):
  CMakeLists.txt:64 (include)

see

  unixodbc >= 2.3.0 required.

However, it looks like installed for me

user@ubuntu:~/clickhouse-odbc/build$ apt list --installed 'unixodbc'
Listing... Done
unixodbc/xenial,now 2.3.1-4.1 amd64 [installed,automatic]

OS Ubuntu 16.04

user@ubuntu:~/clickhouse-odbc/build$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"

Any ideas would be appreciated, thanks!

SQLNumParams support

Hi,

Could you please look into the issue with turbodbc (python library) that I ran into. It seems that Clickhouse ODBC doesn't support one of the core ODBC features and I'm just currious if it's possible to fix it somehow.

blue-yonder/turbodbc#144

ODBC with Tableau Nullable Integers

Hi, I'm faced with a problem. When the Tableau tries to read data from the Nullable Int or UInt columns containing Null then it produces the following error "Syntax error: Not a valid integer: ᴺᵁᴸᴸ." (or unsigned integer in other case). There are no problems wtih tables where Null is missing. Is there any method to avoid such error except replace all Nulls in data?
Trying with:
Tableau 10.4,
Tableau 2018.1,
ClickHouse 1.1.54385,
ClickHouse 1.1.54388
tableau

Add support for compression

Hello we are trying to do massive insert thru the ODBC drivers of clickhouse and we are not reaching good performances ( compare to what we have with jdbc).
After looking what is sent and received from the ODBC client compare to the jdbc one, we can see that data are not compress at all with the ODBC driver. Due to this lack of compression , the network is becoming the main bottleneck.

Is there any plan to add compression support in the ODBC drivers ?

Thanks in advance

ODBC driver is not working on Mac OS X

Hi! I started clickhouse server in the Docker container and built the ODBC driver following @ztlpn instructions (#35). But queries are not executed in isql:

MacBook-Pro-Roman:~ roman$ cat .odbc.ini
[ch]
Driver=/opt/clickhouse-odbc/build/driver/clickhouse-odbc.dylib
Description=ClickHouse driver
DATABASE=default
SERVER=172.17.0.2
PORT=8123
FRAMED=0
MacBook-Pro-Roman:~ roman$ isql -v ch
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select 1;
[S1000]Timeout

Int and Date datatypes is not accessible from tableau

First of all thank you for your product. But I'm faced with issue in using it from Tableau.

Error appears in Tableau while trying to use columns with (Int8,Int16,Int32,Int64,Date,DateTime) datatype in ClickHouse.
ODBC driver tries to send to CH query:

SELECT SUM({fn CONVERT(test_tableau.i, SQL_BIGINT)}) AS sum_i_ok FROM test_tableau HAVING (COUNT(1) > 0)

Obviously as a result it returns:

syntax error

I'm using the last realese of driver (2017-11-07) and ClickHouse v.1.1.54310

ODBC под Windows продолжение...

Пробую добраться до данных в кликхаусе стандартными средствами Windows - через ODBC и Excel.

Похоже что 32 битный Еxcel (офис 2010) требует наличия 32-битного драйвера ODBC на 64-битной системе (Windows 7). При этом если поставить только 32-битный драйвер то настроить DSN из панели управления не получается.

Но это всё вступление (может кому-то и оно пригодится). Теперь к проблемам.

Из экселя пробую вытащить данные. Если использую Unicode драйвер, то Microsoft Query просто умирает. Сообщение об ошибке в журнале событий такое:
Имя сбойного приложения: MSQRY32.EXE, версия: 14.0.7010.1000, отметка времени: 0x511cfec4
Имя сбойного модуля: ODBC32.dll, версия: 6.1.7601.17514, отметка времени 0x4ce7b964
Код исключения: 0xc0000409
Смещение ошибки: 0x00056a09
Идентификатор сбойного процесса: 0x15f4
Время запуска сбойного приложения: 0x01d34d109c72c044
Путь сбойного приложения: C:\Program Files (x86)\Microsoft Office\Office14\MSQRY32.EXE
Путь сбойного модуля: C:\Windows\system32\ODBC32.dll
Код отчета: dcc5f386-b903-11e7-8c07-7824af8aa99d
(не очень полезно наверное, но не знаю что ещё приложить)

С ANSI-драйвером - запускается, но дальше тоже всё не весело:

Таблицы с полями типа Enum не работают - ошибка такая: Can't pase name of type: Enum8('VALID' = 1, 'DELETED' = 2)

Таблицы без Enum - при попытках селектов возвращают исключение DB::Exception: Unknown identifier: table.column, e.what() = DB::Exception

В query_log это выглядит так:

Row 22:
───────
type: 3
event_date: 2017-10-25
event_time: 2017-10-25 21:38:22
query_start_time: 2017-10-25 21:38:22
query_duration_ms: 0
read_rows: 0
read_bytes: 0
written_rows: 0
written_bytes: 0
result_rows: 0
result_bytes: 0
memory_usage: 0
query: SELECT table.сolumn\r\nFROM db.table table
exception: Code: 47, e.displayText() = DB::Exception: Unknown identifier: table.column, e.what() = DB::Exception
stack_trace: 0. clickhouse-server(StackTrace::StackTrace()+0x16) [0x2863bf6]\n1. clickhouse-server(DB::Exception::Exception(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, int)+0x1f) [0x1005e1f]\n2. clickhouse-server(DB::ExpressionAnalyzer::getRequiredColumnsabi:cxx11+0xf3) [0x2bcf9e3]\n3. clickhouse-server(DB::InterpreterSelectQuery::executeFetchColumns()+0x71) [0x27c8301]\n4. clickhouse-server(DB::InterpreterSelectQuery::executeSingleQuery()+0x23) [0x27c60d3]\n5. clickhouse-server(DB::InterpreterSelectQuery::executeWithoutUnion()+0x1a5) [0x27c7c35]\n6. clickhouse-server(DB::InterpreterSelectQuery::execute()+0x22) [0x27c7c82]\n7. clickhouse-server() [0x284db27]\n8. clickhouse-server(DB::executeQuery(DB::ReadBuffer&, DB::WriteBuffer&, bool, DB::Context&, std::function<void (std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)>)+0x1dd) [0x284ec7d]\n9. clickhouse-server(DB::HTTPHandler::processQuery(Poco::Net::HTTPServerRequest&, HTMLForm&, Poco::Net::HTTPServerResponse&, DB::HTTPHandler::Output&)+0x19ff) [0x100e06f]\n10. clickhouse-server(DB::HTTPHandler::handleRequest(Poco::Net::HTTPServerRequest&, Poco::Net::HTTPServerResponse&)+0x31c) [0x100fa9c]\n11. clickhouse-server(Poco::Net::HTTPServerConnection::run()+0x2c0) [0x30ba360]\n12. clickhouse-server(Poco::Net::TCPServerConnection::start()+0xf) [0x30b336f]\n13. clickhouse-server(Poco::Net::TCPServerDispatcher::run()+0x12b) [0x30b49eb]\n14. clickhouse-server(Poco::PooledThread::run()+0xa7) [0x31c7357]\n15. clickhouse-server(Poco::ThreadImpl::runnableEntry(void*)+0x96) [0x31c1ab6]\n16. /lib64/libpthread.so.0(+0x7e25) [0x7f3a1bb99e25]\n17. /lib64/libc.so.6(clone+0x6d) [0x7f3a1946b34d]\n
is_initial_query: 1
user: user
query_id: 55610de4-7f0b-403a-8b2c-067e7546763f
address: \0\0\0\0\0\0\0\0\0\0▒▒W̖▒
port: 26758
initial_user: user
initial_query_id: 55610de4-7f0b-403a-8b2c-067e7546763f
initial_address: \0\0\0\0\0\0\0\0\0\0▒▒W̖▒
initial_port: 26758
interface: 2
os_user:
client_hostname:
client_name:
client_revision: 0
http_method: 2
http_user_agent:
quota_key:
revision: 54236

Похоже это связано с тем что версия сервера относительно старая, ещё без поддержки SELECT table.column. На сервере с новой версией вроде бы работает, но там пока нет данных.

Не работает ODBC connection в Visual Studio для модели SSAS Tabular

Добрый день. Требуется загрузить данные из ClickHouse в табличную модель (разрабатываем ее с помощью ssas tabular в Visual Studio).
При тестировании соединения Visual Studio вываливается с ошибкой:
"Problem signature:
Problem Event Name: BEX
Application Name: devenv.exe
Application Version: 14.0.25420.1
Application Timestamp: 57685d85
Fault Module Name: ODBC32.dll
Fault Module Version: 6.3.9600.17415
Fault Module Timestamp: 545046b6
Exception Offset: 00076051
Exception Code: c0000409
Exception Data: 00000002
OS Version: 6.3.9600.2.0.0.16.7
Locale ID: 1049
Additional Information 1: 4df3
Additional Information 2: 4df3f3134502cdd8f0201ea0e58fbfb9
Additional Information 3: 0d10
Additional Information 4: 0d10de8a9ed5d00e8e5ce3ccf51eda35

Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=280262

If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt"

Отладка не запускается

devenv.exe' (Win32): Loaded 'C:\Program Files (x86)\ClickHouse ODBC\clickhouseodbcw.dll'. Cannot find or open the PDB file.
'devenv.exe' (Win32): Loaded 'C:\Program Files (x86)\ClickHouse ODBC\PocoFoundation.dll'. Module was built without symbols.
'devenv.exe' (Win32): Loaded 'C:\Program Files (x86)\ClickHouse ODBC\PocoNet.dll'. Module was built without symbols.

Подскажите, пожалуйста, в чем может быть проблема?

ODBC parameters substitution

There's a problem with query parameters substitution in the driver. For example here's a query in Tableau:

SELECT  
    site, date, toString(date) as date1, uniqExact(uid) as uv,  uniq(uid) as uv0, count() as vv   
from 
    groot3.content_watch
where 
    date>= <Parameters.date_from> and date< <Parameters.date_to>
group by site, date, toString(date)

The driver receives a translated query:

SELECT  
    site, date, toString(date) as date1, uniqExact(uid) as uv,  uniq(uid) as uv0, count() as vv   
from 
    groot3.content_watch
where 
    date>= {d '2017-07-01'} and date< {d '2017-07-02'}
group by site, date, toString(date)

and it must convert d'2017-07-01' statement to a correct Clickhouse date but is does not and there's an error executing this query.

Compiling on alpine linux

[ 99%] Building CXX object driver/CMakeFiles/clickhouse-odbc.dir/statement.cpp.o
[100%] Linking CXX shared library clickhouse-odbc.so
/usr/lib/gcc/x86_64-alpine-linux-musl/5.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lodbc
collect2: error: ld returned 1 exit status
driver/CMakeFiles/clickhouse-odbc.dir/build.make:304: recipe for target 'driver/clickhouse-odbc.so' failed
make[2]: *** [driver/clickhouse-odbc.so] Error 1
CMakeFiles/Makefile2:326: recipe for target 'driver/CMakeFiles/clickhouse-odbc.dir/all' failed
make[1]: *** [driver/CMakeFiles/clickhouse-odbc.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

I'm using @frol's alpine-glibc image as base.

I have unixodbc-dev installed. What am I missing?
Could You provide a Dockerfile (either ubuntu, debian, alpine)?

Excel + ODBC

Trying to connect to ClickHouse from Excel.
ODBC driver - just built from master branch 32-bit source.
Connection string:

DSN=CH ANSI;DATABASE=default;SERVER=192.168.74.166;PORT=8123;UID=default;

As a result see the following error:
excel_error

For the following Excel configuration
excel

tcpdump on CLickHouse's side on port 8123 caught data exchange

user@ubuntu:~$ sudo tcpdump port 8123 -vv -s 512
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 512 bytes
09:08:23.950916 IP (tos 0x0, ttl 128, id 2201, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.74.177.1198 > 192.168.74.166.8123: Flags [S], cksum 0xc7e5 (correct), seq 2686430201, win 8192, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
09:08:23.950962 IP (tos 0x0, ttl 64, id 7015, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.74.166.8123 > 192.168.74.177.1198: Flags [R.], cksum 0x28a5 (correct), seq 0, ack 2686430202, win 0, length 0
09:08:24.468841 IP (tos 0x0, ttl 128, id 2202, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.74.177.1198 > 192.168.74.166.8123: Flags [S], cksum 0xc7e5 (correct), seq 2686430201, win 8192, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
09:08:24.468913 IP (tos 0x0, ttl 64, id 7022, offset 0, flags [DF], proto TCP (6), length 40)
    192.168.74.166.8123 > 192.168.74.177.1198: Flags [R.], cksum 0x28a5 (correct), seq 0, ack 1, win 0, length 0

So, ClickHouse is accessible for Excel

Please, advise!

Driver ignores settings from odbc.ini

Despite of HOST and PORT defined in /etc/odbc.ini or ~/.odbc.ini, the driver uses default settings from driver/connection.h.

As far as I could dig down, Connection::init(const std::string & connection_string) gets connection_string="DNS=clickhouse", extracts DSN and does nothing with it.

Guess we have two servers: clickhouse.lxd and clickhouse2.lxd

root@clickhouse2:~# cat /etc/odbc.ini 
[clickhouse]
Driver = /usr/local/lib/clickhouse_odbc.so
Description = ClickHouse
DATABASE = default
HOST = clickhouse.lxd
PORT = 9000
FRAMED = 0
root@clickhouse2:~# cat ~/.odbc.ini 
root@clickhouse2:~# 

We are trying to connect from clickhouse2.lxd to clickhouse.lxd and execute simple query: select hostName() from system.one. We expect to get clickhouse as the result.
At first, lets do this with clickhouse-client:

root@clickhouse2:~# clickhouse-client --host clickhouse.lxd --query "select hostName() from system.one format PrettyCompact"
┌─hostName()─┐
│ clickhouse │
└────────────┘

Correct.

Now lets make the same query via ODBC. It should produce the same result since both methods should execute query on the same host.

root@clickhouse2:~# echo "select hostName() from system.one" | iusql -b clickhouse
SQLAllocHandle
+------------+
| hostName() |
+------------+
| clickhouse2|
+------------+
SQLRowCount returns 1
1 rows fetched

Wrong! ODBC driver has ignored our settings and connected to localhost!

Lets look into strace:

root@clickhouse2:~# echo "select hostName() from system.one" | strace -f -e 'trace=network' iusql -b clickhouse 2>&1 | grep INET
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(8123), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)

The same effect takes place on Ubuntu 16.04 (unixODBC 2.3.1) and Ubuntu 14.04 (unixODBC 2.2.14).

Работа клиентского таймаута в новых версиях драйвера

В версиях драйвера после 2017-11-07 перестал корректно задаваться таймаут, который сделали в #36. Если не удается получить от сервера результат в течение 30 сек., то драйвер возвращает ошибку Timeout, не смотря на значительно больший таймаут в настройках ODBC. С драйвером 2017-11-07 таких проблем нет. OC Windows 10 и 8.1. Клиент - Tableau desktop 10.3

Erlang odbc:param_query not working with Clickhouse ODBC driver

I tried to execute the query using Erlang ODBC client. This code not working:

odbc:start().
{ok, Ref} = odbc:connect("DSN=Clickhouse", []).
odbc:param_query(Ref, "SELECT * FROM test WHERE app_id = ?", [{sql_integer, [1]}]).

Error message:

{error,connection_closed}

=ERROR REPORT==== 21-Aug-2017::12:44:19 ===
ODBC: received unexpected info: {tcp_closed,#Port<0.541>}


=ERROR REPORT==== 21-Aug-2017::12:44:19 ===
** Generic server <0.79.0> terminating 
** Last message in was {#Port<0.539>,{exit_status,22}}
** When Server state == {state,#Port<0.539>,
                               {<0.77.0>,#Ref<0.2986369631.1162870785.139969>},
                               <0.77.0>,undefined,on,false,false,on,connected,
                               undefined,0,
                               [#Port<0.537>,#Port<0.538>],
                               #Port<0.540>,#Port<0.541>}
** Reason for termination == 
** {port_exit,could_not_bind_data_buffers}

But this code works correctly (without params):

odbc:param_query(Ref, "SELECT * FROM test WHERE app_id = 1", []). 

Cannot change the timeout for Tableau

Somehow when I connect Tableau to clickhouse server through the ODBC there's not timeout configuration and any query taking longer than 30s will pop up bad connection error. Please help to resolve this problem.

ODBC Driver под .NET

Собрал драйвер под Ubuntu от коммита e062efe
Далее создал простой проект в Rider со следующим кодом:

using System;
using System.Data.Odbc;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var builder = new OdbcConnectionStringBuilder();
            builder.Driver = "/home/denis/sources/clickhouse-odbc/build/driver/libclickhouseodbc.so";
            builder.Add("SERVER", "localhost");
            builder.Add("DATABASE", "default");
            builder.Add("PORT", 8123);
            builder.Add("FRAMED", 0);
            var connection = new OdbcConnection(builder.ConnectionString);
            connection.Open();

            Console.WriteLine(connection.ServerVersion);

            var command = connection.CreateCommand();
            command.CommandText = "select 1";

            var reader = command.ExecuteReader();
            
            connection.Close();
        }
    }
}

Получаю ошибку:

/usr/share/dotnet/dotnet /home/denis/RiderProjects/ConsoleApp1/ConsoleApp1/bin/Debug/netcoreapp2.0/ConsoleApp1.dll
01.00.0000

Unhandled Exception: System.Data.Odbc.OdbcException: ERROR [HY000] HTTP status code: 500
Received error:
Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 9: 
   at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
   at ConsoleApp1.Program.Main(String[] args) in /home/denis/RiderProjects/ConsoleApp1/ConsoleApp1/Program.cs:line 24

Support all the types of columns

I think it's really bad that you can't use table at all because it have some columns of unsupported type, for example Enum8 / Array etc.

It seems that at the beginning the simplest way is to just add a fallback to recognize all currently unsupported column types as String. After that you can at least start use the table data.

Of course accurate support of all the existing types is better and should be priority, but probably will require more time, and delay the release of usable version of odbc driver.

Strings truncation

We have a dictionary with string values. When I select a value using JDBC driver everything is OK:

select dictGetString('subsite', 'title', toUInt64(1303))

"Gambit-html5-android"

The same query executed by the ODBC driver in Tableau yelds "Gambit-html5-an". All strings are truncated to first 15 characters. Same is true for ordinary non-dictionary tables.

Clickhouse как linked сервер в MSSQL

Возникают ошибки, хотя из других приложений успешно подключается, вообще у кого-то работает эта связка?

isql symbol lookup error: undefined symbol: SQLGetPrivateProfileString

Hi. I've built driver on CentOS7 (ODBC - Release 2018-08-16)

after building and adjusting odbc.ini and odbcinst.ini files and invoking isql I'm getting this error:

isql clickhouse -v
isql: symbol lookup error: /home/centos/clhsdrv/clickhouse-odbc/build/driver/libclickhouseodbc.so: undefined symbol: SQLGetPrivateProfileString

content of the isql trace

[ODBC][12110][1534501009.511514][__handles.c][460]
Exit:[SQL_SUCCESS]
Environment = 0x1334750
[ODBC][12110][1534501009.511671][SQLAllocHandle.c][377]
Entry:
Handle Type = 2
Input Handle = 0x1334750
[ODBC][12110][1534501009.511694][SQLAllocHandle.c][493]
Exit:[SQL_SUCCESS]
Output Handle = 0x1335080
[ODBC][12110][1534501009.511713][SQLConnect.c][3721]
Entry:
Connection = 0x1335080
Server Name = [clickhouse_47][length = 13 (SQL_NTS)]
User Name = [NULL]
Authentication = [NULL]
UNICODE Using encoding ASCII 'UTF-8' and UNICODE 'UCS-2LE'

Output of the make execution is attached

Also I've built same release on ubuntu and it works normally

ODBC 64 bit not usable from different tools

Hi All,

I've tested the ODBC 64 bit ( 2017-11-07 018c1d1 installed with the msi on win 7)
with different tool

  • QlikView (Nov 2017 SR1 release) : Can connect but not query "ODBC error Connector reply error: SQL##f - SqlState: HY000, ErrorCode: 1, ErrorMsg: Timeout"

  • Query Tool ODBC 64bit (http://www.gpoulose.com/) : Can not connect "Unsuported info type: 15 State:HY000, ErrorCode: 1"

  • PowerBI (2.53.4954.621 64-bit December, 2017) : Can not connect "ODBC: ERROR [HY000] Timeout"

Any idea Why ?
How to use the ODBC client in windows with a BI tool ?

thank-you.

I/O error with Linux driver

Hello!
I built ODBC driver for Linux (build passed without any errors, master branch). But ODBC driver can perform only one query per connection, second query throws I/O error. For example, this error reproduces in isql:

vagrant@vagrant-ubuntu-trusty-64:~$ isql clickhouse -v
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> show tables
+------+
| name |
+------+
| test1|
| test2|
+------+
SQLRowCount returns 2
2 rows fetched
SQL> show tables
[S1000][unixODBC]I/O error
SQL> 

I use this driver in Erlang application and this error there also happens.
I tried to build driver on local machine, on Vagrant and on CircleCI container. And this error is reproduced everywhere.

Tableau compatibility Issues : mathematical function not working

I'm using Tableau 18.3 beta with Clickhouse version :18.12.13 and Clickhouse ODBC driver version:1.0.0.20180903

When using calculated fields in tableau with the Log function tableau report the following error (i've simplified the request for reporting the bug )
I 've tried with many of the function present in tableau ( COS , CEILING , LOG ) , they all produce the same result.
:

HTTP status code: 500 Received error: Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 55 (line 1, col 55): {fn LOG10(Custom_SQL_Query.z)} ELSE NULL END)) AS sum_Calculation_1621295916296810500_ok, SUM(toInt64(Custom_SQL_Query.x)) AS sum_x_ok, SUM(toIn. Unrecognized token, e.what() = DB::Exception
SELECT SUM((CASE WHEN Custom_SQL_Query.z > 0 THEN {fn LOG10(Custom_SQL_Query.z)} ELSE NULL END)) AS sum_Calculation_1621295916296810500_ok,
SUM({fn CONVERT(Custom_SQL_Query.x, SQL_BIGINT)}) AS sum_x_ok,
SUM({fn CONVERT(Custom_SQL_Query.y, SQL_BIGINT)}) AS sum_y_ok
FROM (
select c+1 as x,c+2 as y,c as z,arrayJoin(array(1,2,3,4) )as c
) Custom_SQL_Query
HAVING (COUNT(1) > 0)

The ODBC error connect Power BI

Hi all,
I tried to use the Power BI to connect clickhouse odbc driver while met the following error:

Feedback Type:
Frown (Error)

Timestamp:
2018-07-12T06:23:06.6483545Z

Local Time:
2018-07-12T14:23:06.6483545+08:00

Session ID:
4004306b-ba15-4bc7-966c-9c202418c1f6

Release:
June 2018

Product Version:
2.59.5135.781 (PBIDesktop) (x64)

Error Message:
OLE DB or ODBC error: [DataSource.Error] ODBC: ERROR [HY000] HTTP status code: 500
Received error:
Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 12 (line 1, col 12): 1000001
TimeStamp
from default.TrafficTable4
group by TimeStamp. Expected one of: identifier, alias, AS, token, AND, OR, UNION ALL, BETWEEN, IS, LIKE, NOT LIKE, IN, NOT IN, GLOBAL IN, GLOBAL NOT IN, Comma, Dot, Arrow, QuestionMark, ORDER BY, SETTINGS, INTO OUTFILE, FORMAT, FROM, PREWHERE, WHERE, WITH, HAVING, LIMIT, GROUP BY, e.what() = DB::Exception

OS Version:
Microsoft Windows NT 10.0.17134.0 (x64 zh-CN)

CLR Version:
4.7 or later [Release Number = 461808]

Peak Virtual Memory:
38.2 GB

Private Memory:
329 MB

Peak Working Set:
466 MB

IE Version:
11.112.17134.0

User ID:
db8cee20-5c05-4896-8470-a1fa38cf1cee

Workbook Package Info:
1* - zh-CN, Query Groups: 0, fastCombine: Disabled, runBackgroundAnalysis: True.

Telemetry Enabled:
True

Model Default Mode:
DirectQuery

Snapshot Trace Logs:
C:\Users\wenzhao\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot977727484.zip

Performance Trace Logs:
C:\Users\wenzhao\AppData\Local\Microsoft\Power BI Desktop\PerformanceTraces.zip

Enabled Preview Features:
CustomConnectors

Disabled Preview Features:
PBI_shapeMapVisualEnabled
PBI_EnableReportTheme
PBI_newFromWeb
PBI_SpanishLinguisticsEnabled
PBI_qnaExplore
PBI_variationUIChange
PBI_canvasTooltips
PBI_showIncrementalRefreshPolicy

Disabled DirectQuery Options:
PBI_DirectQuery_Unrestricted
TreatHanaAsRelationalSource

Cloud:
MSIT

DPI Scale:
100%

Supported Services:
Power BI

Formulas:

section Section1;

shared TrafficTable4 = let
Source = DirectCH.Database("ClickhouseA"),
TrafficTable4_Table = Source{[Name="TrafficTable4",Kind="Table"]}[Data]
in
TrafficTable4_Table;

Wenjing Zhao

Производительность драйвера

Выгружаем 9 млн строк (1 ГБ) из кликхауса через ODBC драйвер под Windows 8.1 в Tableau. Это занимает 20 минут. Если тоже самое грузить через JDBC драйвер, то это займет 3 минуты. При этом основное время для ODBC драйвера приходится на передачу данных пачками по 1400 байт (судя по wireshark).

Timeout в 30 сек.

session.setTimeout(Poco::Timespan(30, 0));

можно сделать этот параметр настраиваемым при создании источника данных?

Python 3/PHP 7 + ODBC drivers issues

Hello everyone!

Making first steps with ODBC driver and Python3. Having couple of issues on the way.
Preparation:

    CREATE TABLE default.books (
        id Int32,
        name String,
        added Date
    ) ENGINE = MergeTree(added, id, 8192)

    INSERT INTO
        default.books
    VALUES
        (1, "Book 1", "2017-08-21"),
        (2, "Book 2", "2017-08-22")
 clickhouse-client -q "select id,name,added from default.books"
1       Book 1  2017-08-21
2       Book 2  2017-08-22

Now simple Python ODBC program:

import pyodbc
dsn = 'DSN=ClickHouse;UID=default;PWD='
connection = pyodbc.connect(dsn)
cursor = connection.cursor()
query = """
        SELECT
                id,
                name,
                added
        FROM
                default.books
"""
print("Query:", query)
cursor.execute(query)
while True:
        try:
                row = cursor.fetchone()
        except Exception as e:
                print(e)

        if not row:
                break

        print('Row:', str(row))

connection.close()
user@ubuntu:~$ python3 e.py
Query:
        SELECT
                id,
                name,
                added
        FROM
                default.books

('HY000', "[HY000] Cannot interpret '2017-08-21' as DateTime (1) (SQLGetData)")

Ok, remove problematic added field - but still no luck - now strings are corrupted.

user@ubuntu:~$ python3 e.py
Query:
        SELECT
                id,
                name
        FROM
                default.books

Row: (1, '潂歯ㅯォ@Q')
Row: (2, '潂歯㉯ォ@R')

Please, advise! May be my code is wrong? Thanks in advance!

Int64 support error

Hi,
Does this odbc driver support the Int64 type? because I just get error when connect to Power BI if the table have Int64 type.
When will it support the Int64 type?
Thanks.

Wenjing Zhao

Errors when you try to connect from Erlang, driver release '2018-03-21'

Error occurs in Erlang, driver release version is 2018-03-21, but with previous release there is no error.

1> odbc:start().
ok
2> {ok, Ref} = odbc:connect("DSN=clickhouse", []).

=ERROR REPORT==== 26-Mar-2018::07:12:27 ===
ODBC: received unexpected info: {tcp_closed,#Port<0.541>}


=ERROR REPORT==== 26-Mar-2018::07:12:27 ===
** Generic server <0.68.0> terminating 
** Last message in was {#Port<0.539>,{exit_status,5}}
** When Server state == {state,#Port<0.539>,
                               {<0.61.0>,#Ref<0.967934967.3703570433.6819>},
                               <0.61.0>,undefined,on,undefined,undefined,on,
                               connecting,undefined,0,
                               [#Port<0.537>,#Port<0.538>],
                               #Port<0.540>,#Port<0.541>}
** Reason for termination == 
** {port_exit,freeing_of_memory_failed}
** exception error: no match of right hand side value {error,connection_closed}

But isql tool works fine.

Tableau ODBC - connection refused

I'm trying to connect Tableau (2018.2) to my Clickhouse db running on AWS EC2. Using the latest 64-bit ODBC driver with public DNS of the EC2 instance as host, default as user and db, port 8123, PROTO=http.

Connection to EC2 works however no tables are found by Tableau and when I try a Custom SQL query from Tableau I get the following error:

Connection refused:
Generic ODBC requires additional configuration. The driver and DSN (data source name) must be installed and configured to match the connection.
Unable to connect using the DSN named "ClickHouse". Check that the DSN exists and is a valid connection.

Running Sudo netstat -tulpn I get:

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9009 0.0.0.0:* LISTEN 1585/clickhouse-ser
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1529/sshd
tcp 0 0 127.0.0.1:8123 0.0.0.0:* LISTEN 1585/clickhouse-ser
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1585/clickhouse-ser
tcp6 0 0 ::1:9009 :::* LISTEN 1585/clickhouse-ser
tcp6 0 0 :::22 :::* LISTEN 1529/sshd
tcp6 0 0 ::1:8123 :::* LISTEN 1585/clickhouse-ser
tcp6 0 0 ::1:9000 :::* LISTEN 1585/clickhouse-ser
udp 0 0 0.0.0.0:68 0.0.0.0:* 1134/dhclient
udp 0 0 0.0.0.0:46847 0.0.0.0:* 1134/dhclient
udp6 0 0 :::45433 :::* 1134/dhclient

Tableau compatibility Issues : View type are not exposed correctly

I'm using Tableau 18.3 beta with Clickhouse version :18.12.13 and Clickhouse ODBC driver version:1.0.0.20180903

I'm using a view to access a table with states. This view contain a datetime field ( which is correctly view from other tools such as tabix ...).
When using the view in tableau , the date_time field in exposed as a string.

Thanks

Nullable columns issues

While querying a table with nullable columns from Tableau using 11-07 build I have Syntax error. The query is

select platforms from gamora.params where platforms is null limit 1

Tableau wraps it and generates the following query:

SELECT `Custom_SQL_Query`.`platforms` AS `platforms`
FROM (
  select platforms from gamora.params where platforms is null limit 1
) `Custom_SQL_Query`
GROUP BY `platforms`

that leads to the error. The query is OK and according to Wireshark dump CH replues HTTP OK with data.

:) SELECTCustom_SQL_Query.platformsASplatformsFROM ( select platforms from gamora.params where platforms is null limit 1 )Custom_SQL_QueryGROUP BYplatforms`

SELECT Custom_SQL_Query.platforms AS platforms
FROM (
select platforms
from gamora.params
where platforms is null
limit 1
) Custom_SQL_Query
GROUP BY platforms

┌─platforms─┐
│ \N │
└───────────┘

Ok. 1 row in set. Elapsed: 0.017 sec. Processed: 0.0 rows, 0.0B (0.0 rows/s, 0.0B/s)
`

`show create table gamora.params

CREATE TABLE gamora.params ( user_id Int64, date Date, dt DateTime, p1 Nullable(Int32), platforms Nullable(Int32), max_position Nullable(Int32), vv Nullable(Int32), city Nullable(String), third_party Nullable(Int8), mobile_tablet Nullable(Int8), mobile_phone Nullable(Int8), desktop Nullable(Int8), web_mobile Nullable(Int8), tv_attach Nullable(Int8), smart_tv Nullable(Int8), subsite_id Nullable(Int32), view_in_second Nullable(Int32), view_in_second_presto Nullable(Int32)) ENGINE = MergeTree(date, user_id, 8192)
`

OLE DB provider "STREAM" for linked server "(null)" return message "Требуемое преобразование не поддерживается"

В MSSQL Server 2017 настроен linked server к ClickHouse через ODBC драйвер, при выполнении запроса и выборе столбцов типа String получаю такую ошибку: OLE DB provider "STREAM" for linked server "(null)" return message "Требуемое преобразование не поддерживается"
Однако, столбцы типа int, date, выводятся без проблем.
Версия MS SQL Server 2017 , Clickhouse v1.1.54370, ODBC драйвер версия x64 от 2018-03-21

odbc driver building on MacOS

Hello,

Is it possible to build this driver on MacOS? I've tried to built this driver on MacOS but my try failed.

First, you need to replace this: #include <malloc.h> with this #include "/usr/include/malloc/malloc.h" in all files, because only including with absolute path works (I don't know why).

Second, you need to replace SQLColAttribute constant everywhere with some other name (e.g. SQLColumnAttribute), because this name already used by some of the SQL libraries on MacOS.

Third, some compilation options (e.g. -static-libgcc) and some others don't support on MacOS.

And the last thing, into the ./driver/CMakeFiles/clickhouse-odbc.dir/cmake_clean.cmake file we see "clickhouse-odbc.dylib" removing. This strange because the .dylib file is the goal we want to reach after building.

And then we successfully get clickhouse-odbc.dylib driver and connect it with odbc.ini file we get "Segmentation fault" after using it.

May be I'm wrong and this driver could be built only on Linux, but may be this information will help somebody.

Thanks.

ODBC with Tableau 2

Hello, I have one more case (in addition to #67)

Query:

SELECT `adv_watch`.`rocket_date` AS `rocket_date`,
  COUNT(DISTINCT `adv_watch`.`ivi_id`) AS `usr_Calculation_683139814283419648_ok`
FROM `adv_watch`
WHERE ((`adv_watch`.`rocket_datetime` >= {fn TIMESTAMPADD(SQL_TSI_DAY,-9,CAST({fn CURRENT_TIMESTAMP(0)} AS DATE))}) AND (`adv_watch`.`rocket_datetime` < {fn TIMESTAMPADD(SQL_TSI_DAY,1,CAST({fn CURRENT_TIMESTAMP(0)} AS DATE))}))
GROUP BY `adv_watch`.`rocket_date`

Error message:

HTTP status code: 500 Received error: Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 192 (line 4, col 42): {fn TIMESTAMPADD(SQL_TSI_DAY,-9,CAST({fn CURRENT_TIMESTAMP(0)} AS DATE))}) AND (`adv_watch`.`rocket_datetime` < {fn TIMESTAMPADD(SQL_TSI_DAY,1,CAST({fn CURRENT_. Unrecognized token, e.what() = DB::Exception

Data source name not found and no default driver

Hi,

I am trying to connect from c#+.Net throught odbc.

Below is the code i have
var builder = new OdbcConnectionStringBuilder();
builder.Driver =
"E:\MySpace\Downloads\clickhouse-odbc-master\vs\x64\clickhouseodbc.dll";
builder.Add("SERVER", "cagatHDN01.iv.local");
builder.Add("DATABASE", "default");
builder.Add("PORT", 8123);
builder.Add("FRAMED", 0);
var connection = new OdbcConnection("Driver = Click House ANSI; Host = ; Port =");
//Also tried below
//var connection = new OdbcConnection(builder.ConnectionString);
connection.Open();
return connection;

When I run, I have the exception:
System.Data.Odbc.OdbcException: 'ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified'.

I have also installed the driver and configured as in
t

Build clickhouse-odbc on windows os error

Hi all,
I tried to build clickhouse-odbc driver on windows os refer to the readme reference but met some error like follows:

  1. I have tried to run the build_vs.bat in the vs folder while met the error:
    'devenv' Not an internal or external command, nor a runnable program or batch file.
    'msbuild' Not an internal or external command, nor a runnable program or batch file.
    Just like I need to build other project before run the build_vs.bat

  2. I have tried to use the cmake to generate the project while met error following:

The C compiler identification is MSVC 19.14.26430.0
The CXX compiler identification is MSVC 19.14.26430.0
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMAKE_BUILD_TYPE:
Using ssl=1: C:/Users/wenzhao/clickhouse-odbc/contrib/ssl/include : ssl;crypto
Using ltdl: LTDL_LIBRARY-NOTFOUND
Could NOT find ODBC (missing: ODBC_INCLUDE_DIRECTORIES ODBC_LIBRARIES)
Using odbc: ODBC_INCLUDE_DIRECTORIES-NOTFOUND : ODBC_LIBRARIES-NOTFOUND
Using Poco: : PocoFoundation,PocoUtil,PocoNet,PocoNetSSL,PocoCrypto
Using nanoodbc= :
Could NOT find ODBC (missing: ODBC_INCLUDE_DIRECTORIES ODBC_LIBRARIES)
Windows native ODBC Support Enabled
Using odbc: ODBC_INCLUDE_DIRECTORIES-NOTFOUND : odbc32;odbccp32
Building for: Windows-10.0.17134 AMD64 ; CCACHE=CCACHE_FOUND-NOTFOUND
Windows AMD64 Windows-10.0.17134 10.0.17134
Using [MSVC] compiler
Looking for asprintf
Looking for asprintf - not found
Looking for inet_pton
Looking for inet_pton - not found
Looking for reallocarray
Looking for reallocarray - not found
Looking for strcasecmp
Looking for strcasecmp - not found
Looking for strlcat
Looking for strlcat - not found
Looking for strlcpy
Looking for strlcpy - not found
Looking for strndup
Looking for strndup - not found
Looking for strsep
Looking for strsep - not found
Looking for timegm
Looking for timegm - not found
Looking for arc4random_buf
Looking for arc4random_buf - not found
Looking for arc4random_uniform
Looking for arc4random_uniform - not found
Looking for explicit_bzero
Looking for explicit_bzero - not found
Looking for getauxval
Looking for getauxval - not found
Looking for getentropy
Looking for getentropy - not found
Looking for getpagesize
Looking for getpagesize - not found
Looking for timingsafe_bcmp
Looking for timingsafe_bcmp - not found
Looking for timingsafe_memcmp
Looking for timingsafe_memcmp - not found
Looking for memmem
Looking for memmem - not found
Looking for include file err.h
Looking for include file err.h - not found
Looking for sys/types.h
Looking for sys/types.h - found
Looking for stdint.h
Looking for stdint.h - found
Looking for stddef.h
Looking for stddef.h - found
Check size of time_t
Check size of time_t - done
Poco package version: 1.9.1
Checking for C++11 compiler
Checking for C++11 compiler - available
Checking for C++14 compiler
Checking for C++14 compiler - available
CMake Error at contrib/poco/cmake/PocoMacros.cmake:33 (message):
message compiler not found: required to build
Call Stack (most recent call first):
contrib/poco/CMakeLists.txt:86 (include)

Configuring incomplete, errors occurred!
See also "C:/Users/wenzhao/clickhouse-odbc/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/wenzhao/clickhouse-odbc/build/CMakeFiles/CMakeError.log".

The visual studio version is visual studio 15 2017.

Thanks for the help~

Wenjing Zhao

TIMESTAMPADD not supported

Trying do vs. LY comparisons in Tableau and getting the following error in Tableau:

Bad Connection: Tableau could not connect to the data source.

Cannot interpret 'ᴺᵁᴸᴸ' as double: invalid stod argument
SELECT stock_denorm.municipality AS municipality,
stock_denorm.region AS region,
SUM((CASE WHEN ({fn TIMESTAMPADD(SQL_TSI_DAY,CAST({fn TRUNCATE((-1 * (EXTRACT(DAY FROM {fn TIMESTAMPADD(SQL_TSI_DAY,-1,stock_denorm.createddate)}) - 1)),0)} AS INTEGER),CAST({fn TIMESTAMPADD(SQL_TSI_DAY,-1,stock_denorm.createddate)} AS DATE))} = {ts '2018-08-01 00:00:00'}) THEN (COALESCE(stock_denorm.soldstock, 0) * COALESCE(stock_denorm.volume, 0)) ELSE NULL END)) AS sum_Calculation_437975098872115206_ok
FROM stock_denorm
GROUP BY municipality,
region

Rewriting the query for better readability and running directly in clickhouse-client (SQL_TSI_DAY replaced with 'day'):
SELECT municipality, region, SUM(multiIf(TIMESTAMPADD('day', CAST(TRUNCATE(-1 * (toDayOfMonth(TIMESTAMPADD('day', -1, createddate)) - 1), 0), 'INTEGER'), CAST(TIMESTAMPADD('day', -1, createddate), 'DATE')) = '2018-06-01 00:00:00', COALESCE(soldstock, 0) * COALESCE(volume, 0), NULL)) AS stockly FROM stock_denorm GROUP BY municipality, region

Yields the following response:

Received exception from server (version 18.10.3):
Code: 46. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Unknown function TIMESTAMPADD.

Add support for Decimal

Привет!

В КХ появилась поддрежка Decimal, но в tableau не видно колонок с типом Decimal.
ODBC драйвер стоит последний (2018-09-03).

Предполагаю - из-за отсутствия поддержки Decimal со стороны ODBC драйвера. Добавите? =)

Разграничение прав пользователей к разным бд

Добрый день, коллеги!

Нам очень нужен функционал, который позволит разграничивать права доступа к бд внутри КХ. Например, у пользователя Х должен быть доступ на Запись к бд1 и только Чтение к бд2.

Чтобы можно было реализовать такую логическую структуру:

database_name user_name access
logger user1 readonly
raw user1 readwrite
raw user2 readonly

юзкейс: у нас много аналитиков, которым нужно дать права на запись только к своим (аналитическим бд) и при этом у них должен быть доступ только на чтение другим бд (туда, куда происходит запись данных от приложений).

query timeout with tableau ODBC

I getting query timeout error after 30 seconds.

I tried setting timeout=100 with connection details but it does nothing.

Here is my tableau connection string:

ODBC под windows / Excel / Microsoft Report Designer

windows 32 /все порты открыты / tabix работает
1.Скачал драйвер
2. Запустил odbcad32.exe (Clickhouse unicode)
Name HOUSE
IP сервера
Порт 8123
Database default
User default
3. создался без ошибок
4. пытаюсь настроить linked server

/****** Object: LinkedServer [X] Script Date: 07/22/2017 01:20:20 *****/
EXEC master.dbo.sp_addlinkedserver @server = N'X', @srvproduct=N'MSDASQL', @Provider=N'MSDASQL', @datasrc=N'HOUSE'
/
For security reasons the linked server remote logins password is changed with ######## */
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'X',@useself=N'False',@locallogin=NULL,@rmtuser=N'default',@rmtpassword='########'

GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'collation compatible', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'data access', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'dist', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'pub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'rpc', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'rpc out', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'sub', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'connect timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'collation name', @optvalue=null
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'lazy schema validation', @optvalue=N'false'
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'query timeout', @optvalue=N'0'
GO
EXEC master.dbo.sp_serveroption @server=N'X', @optname=N'use remote collation', @optvalue=N'true'

  1. Создает linked server без ошибок.

  2. При попытке написать
    Select * from openquery (X, 'select 1 ')

Ошибка Msg 7357, Level 16, State 2, Line 1
Cannot process the object "select 1 ". The OLE DB provider "MSDASQL" for linked server "X" indicates that either the object has no columns or the current user does not have permissions on that object.
7. при попытке обратиться через Excel

TITLE: Microsoft Report Designer

An error occurred while executing the query.
Warning: A StringBuilder buffer has been overflowed by unmanaged code. The process may become unstable. Insufficient capacity allocated to the StringBuilder before marshaling it.


ADDITIONAL INFORMATION:

Warning: A StringBuilder buffer has been overflowed by unmanaged code. The process may become unstable. Insufficient capacity allocated to the StringBuilder before marshaling it. (System.Data)


BUTTONS:

OK

Unknown identifier on Nullable(String) column

Trying to connect from Tableau, using the 2018-02-01 driver release, and getting the following error:

Received error: Code: 47, e.displayText() = DB::Exception: Unknown identifier: loved_songs.title, e.what() = DB::Exception

If it helps, the target table is using the Log engine, with the following schema:

CREATE TABLE test.loved_songs(
title Nullable(String),
song_id Float32,
artist_name Nullable(String),
datetime String) ENGINE  = Log;

I saw a similar error when using an older version of JDBC driver : dbeaver/dbeaver#1959 and so I suspect this problem can persist on ODBC. I can try to provide more info, if necessary.

compile error on centos 7

I am getting below error while compiling. please help.I followed the steps exactly.

[root@centos clickhouse-odbc]# mkdir -p build; cd build && cmake .. && make -j $(nproc || sysctl -n hw.ncpu || echo 4)
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_BUILD_TYPE:
-- BUILD_SHARED=
-- Using ssl=1: /opt/softwares/clickhouse-odbc/contrib/ssl/include : ssl;crypto
-- Using ltdl: LTDL_LIBRARY-NOTFOUND
-- Could NOT find ODBC (missing: ODBC_INCLUDE_DIRECTORIES ODBC_LIBRARIES)
-- Using odbc: ODBC_INCLUDE_DIRECTORIES-NOTFOUND : /usr/lib64/libodbc.so;/usr/lib64/libodbcinst.so;LTDL_LIBRARY-NOTFOUND
-- Using Poco: /opt/softwares/clickhouse-odbc/contrib/poco/NetSSL_OpenSSL/include;/opt/softwares/clickhouse-odbc/contrib/poco/Crypto/include : PocoFoundation,PocoUtil,PocoNet,PocoNetSSL,PocoCrypto,,,,,,; MongoDB=, DataODBC=, NetSSL=
-- Using nanoodbc= :
-- Could NOT find ODBC (missing: ODBC_INCLUDE_DIRECTORIES ODBC_LIBRARIES)
-- Using odbc: ODBC_INCLUDE_DIRECTORIES-NOTFOUND : /usr/lib64/libodbc.so;/usr/lib64/libodbcinst.so;LTDL_LIBRARY-NOTFOUND
-- Using odbc: ODBC_INCLUDE_DIRECTORIES-NOTFOUND : /usr/lib64/libodbc.so;/usr/lib64/libodbcinst.so;LTDL_LIBRARY-NOTFOUND
CMake Error at cmake/Modules/CheckODBCversion.cmake:15 (MESSAGE):
unixodbc >= 2.3.0 required.

RESULT=1 OUTPUT= ERROR=conftest.c:1:39: fatal error: sqlext.h: No such file or directory
#include <sqlext.h>
^

compilation terminated.

Call Stack (most recent call first):
CMakeLists.txt:117 (include)

-- Configuring incomplete, errors occurred!
See also "/opt/softwares/clickhouse-odbc/build/CMakeFiles/CMakeOutput.log".
[root@centos build]# ls

Add Replace function

Hi, add please support of Replace function in ODBC.

Example:

SELECT (toStartOfFiveMinute(`log`.`dfs_datetime`)) AS `Calculation_257268181289402369`,
  {fn REPLACE(`log`.`dfs_host_id`,'-','')} AS `Calculation_257268181501140994`,
  SUM({fn CONVERT(1, SQL_BIGINT)}) AS `sum_Number_of_Records_ok`
FROM `log`
WHERE ((`log`.`dfs_date` >= {d '2018-03-25'}) AND (`log`.`dfs_date` <= {d '2018-03-27'}) AND (`log`.`dfs_host_id` = 'dfs-perm-1'))
GROUP BY `Calculation_257268181289402369`,
  `Calculation_257268181501140994` 

Current error:

HTTP status code: 500 Received error: Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 91 (line 2, col 3): {fn REPLACE(`log`.`dfs_host_id`,'-','')} AS `Calculation_257268181501140994`, SUM(toInt64(1)) AS `sum_Number_of_Records_ok` FROM `log` WHERE ((`log`.`dfs_date. Unrecognized token, e.what() = DB::Exception

ODBC with Tableau

Hi, I have a problem with ODBC using Tableau.

Outcoming query:

SELECT CAST({fn TRUNCATE(EXTRACT(YEAR FROM `adv_watch`.`rocket_date`),0)} AS INTEGER) AS `yr_rocket_date_ok`
FROM `adv_watch`
GROUP BY CAST({fn TRUNCATE(EXTRACT(YEAR FROM `adv_watch`.`rocket_date`),0)} AS INTEGER)

Incoming error message:

HTTP status code: 500 Received error: Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 34 (line 1, col 34): FROM `adv_watch`.`rocket_date`),0) AS INTEGER) AS `yr_rocket_date_ok` FROM `adv_watch` GROUP BY CAST(trunc(EXTRACT('year' FROM `adv_watch`.`rocket_date`),0) AS . Expected one of: alias, AS, token, AND, OR, BETWEEN, IS, LIKE, NOT LIKE, IN, NOT IN, GLOBAL IN, GLOBAL NOT IN, Comma, QuestionMark, e.what() = DB::Exception

Can you fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.