This repository provides a local Docker Compose environment for testing
ClickHouse access to Microsoft SQL Server 2017 through clickhouse-odbc-bridge.
It starts three services:
clickhouse— ClickHouse Server, exposed on8123(HTTP) and9000(native).odbc-bridge— ClickHouse ODBC bridge with Microsoft ODBC Driver 17.mssql— SQL Server 2017 Developer Edition with a small sample table.
The bridge is a sidecar service. ClickHouse sends ODBC requests to it over the
internal Compose network; port 9018 is intentionally not published to the host.
- Docker Engine with Docker Compose v2
- An
amd64Docker runtime. SQL Server 2017 and Microsoft ODBC Driver 17 in this setup arelinux/amd64only.
Create a local environment file and choose a strong SQL Server password:
cp .env.example .env
docker compose up --build -dWait for the mssql-init service to complete successfully:
docker compose psThe initialization service creates testdb.dbo.sample_data. Query it from
ClickHouse through the ODBC bridge:
docker compose exec clickhouse sh -c \
'clickhouse-client --query "SELECT * FROM odbc('\''DSN=mssql2017;UID=$MSSQL_USER;PWD={$MSSQL_PASSWORD}'\'', '\''dbo'\'', '\''sample_data'\'') ORDER BY id"'Expected result:
1 Ada 125.50 2024-01-15 09:30:00
2 Grace 250.00 2024-02-20 14:45:00
3 Linus 375.25 2024-03-10 08:00:00
docker/odbc.ini.template is rendered by the bridge container at startup. Its
values come from .env; do not commit .env. The DSN name is mssql2017 to
make the target explicit, but it can be renamed along with the query above.
The table function receives SQL Server credentials in its ODBC connection
string, which is why the smoke test uses variables injected into ClickHouse.
For a different SQL Server version or deployment, adjust the mssql service
image and the variables in .env. The final bridge image contains only the
bridge binary, its runtime dependencies, unixODBC, and the installed SQL Server
driver. The ClickHouse Server image is used only during the multi-stage build
and is not present in the final image.
docker compose down -v