All notable changes to this project are documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.6.0 - 2026-11-01
Breaking
- Elixir 1.18+ is required (
googleapis, pulled in by grpc, needs it). - One error type. Every function returns
{:error, %Huginn.Error{}}(:reasonis:server,:connection,:timeout,:grpc,:decode,:unexpected_replyor:not_configured;:codeis the ClickHouse error code for:server).query!/2raisesHuginn.Errorinstead of aRuntimeError. stream_rows/2andstream_maps/2raiseHuginn.Erroron failure. They used to drop errors, so an outage looked like an empty result.stream_query/2errors are terminal: an error is always the last element.stream_io/1is replaced bystream_io(sql, input, opts). ClickHouse'sExecuteQueryWithStreamIOruns one query with streamed input and output; the old{output, send_fn}API lost sends made after reading began and skipped the pool's credentials. The new function runs oneINSERT ... SELECT FROM input(...)and returns a lazy stream of results.- TabSeparated and CSV now use ClickHouse's exact escaping. Values
containing tabs, newlines or backslashes used to split columns or, on
insert, forge extra rows.
NULL(\N) decodes tonilandnilencodes to\N. CSV is parsed over the whole buffer, so quoted newlines work, and the CSV writer always quotes strings. insert_stream/3:chunk_sizeis bytes per message (default 1 MiB), as the docs always said; it used to count elements, so the documentedFile.stream!import built ~64 MiB messages. An oversized element is sent alone. An empty source still sends the INSERT.- Structured rows for
JSONEachRowmust be maps; list rows raiseArgumentError— use the newformat: "JSONCompactEachRow". Structured rows for formats the encoder doesn't support raise instead of being joined with tabs. Result.parse_output/3returns{:ok, rows} | {:error, %Huginn.Error{}}and malformed output (bad JSON or escapes) is a:decodeerror instead of a raise. Non-UTF-8 String columns decode to raw binaries.- Retries only cover
:connectionerrors.DEADLINE_EXCEEDED/timeouts are no longer retried.insert/3,insert_stream/3and the streams retry only channel acquisition, so nothing that reached the server is sent twice (a timed-out insert used to be re-sent and could duplicate rows). Backoff is capped by the new:retry_max_backoff(default 5 s) with full jitter.Retry.transient?/1takes aHuginn.Error. - Streaming calls default to
timeout: :infinity(was 60 s, which cut off long streams and large imports). - Config:
from_env/0is removed fromHuginn.Clickhouse.Config. There is no silent fallback tolocalhost; a call on a pool that was never started returns a:not_configurederror.- The
:compressionoption is removed. It never reached the server, and passed per query it returned compressed bytes that were parsed as rows. Huginn.Clickhouse.Config.new/1raisesArgumentErrorfor a missing or invalid:host,:port,:pool_size,:database,:author:ssl, and for unknown options. Messages never include values.with_auth/2is replaced byHuginn.Clickhouse.Query.with_config/2.Huginn.Clickhouse.Query.build_insert/3no longer maps:formatto the output format; the input format is the SQLFORMATclause.
- TLS fails closed.
ssl: trueraises if peer verification isn't available. Anssl:keyword list without:verifygetsverify: :verify_peer, the system CAs (unless you pass:cacerts/:cacertfile) and hostname checking merged underneath; your keys win. Opt out with an explicitverify: :verify_none. - Telemetry
:stopmetadata::rowscomes from the server'sstats.rows,:erroris aHuginn.Error, and early-stopped streams reporthalted: true. - Removed
Result.merge/1and the unusedHuginn.Clickhouse.Streamhelperscollect_output/1,transform_output/2,parse_stream/1,row_stream/1andmap_stream/1. They also mis-decoded every chunk after the first.
Added
- Multiple pools:
Huginn.child_spec/1,Huginn.start_link/1andHuginn.Clickhouse.Poolstart pools in your supervision tree, each with its own host, database and credentials, selected per call withpool:.Huginn.await_ready/2blocks until a pool has a connection. - Telemetry spans for
insert_stream/3,stream_query/2andstream_io/3, with thequery_idthe server actually runs. New[:huginn, :query, :retry]event. - Output formats
JSONCompactEachRow,JSONStringsEachRowandJSONCompactStringsEachRow.
Fixed
- The configured
:databaseis sent with every query. It used to be ignored, so queries ran against the user's default database. - Stopping a stream early cancels the server query. This covers
Enum.take/2, an exception, or the consumer process dying.stream_query/2now runs overExecuteQueryWithStreamIOwith the input side closed. A raisinginsert_stream/3source cancels the insert. - Streaming is flow-controlled in both directions, so memory stays
bounded. grpc-elixir's gun adapter refilled the HTTP/2 receive window on
its own and sent input without waiting for the send window, so a slow
consumer buffered the whole result and a fast source buffered the whole
input.
insert_stream/3,stream_query/2andstream_io/3now run on their own HTTP/2 connection (Mint, passive mode) that is only read as fast as the stream is consumed and only written as fast as the server grants window. Unary calls still use the pool. Reading a large result is also about 3.5× faster. - Cancelling a stream no longer logs grpc's
received unexpected message: {:gun_error, ..., :badstate, ...}warning, because stream cancellation no longer goes through grpc's shared connection process. - Credentials no longer leak.
inspect/1on a config hides:auth, and boot and validation errors don't echo the options. stream_query/2reads replies lazily, one at a time, and no longer falls back to grpc's 10 s receive timeout.
Dependencies
:protobuf~> 0.17.1(keeps dependents off 0.17.0, affected by EEF-CVE-2026-104635). The bindings were regenerated withprotoc-gen-elixir0.17.1;priv/protos/clickhouse_grpc.protoalready matched ClickHousemaster.:grpcis now a direct dependency at~> 1.0.5. grpc_core 1.0.5 stops rounding thegrpc-timeoutsent to the server down, e.g. 90 s → 1 min.- grpc_connection_pool 0.5.3, cowlib 2.21.0 (fixes CVE-2026-43971 and CVE-2026-43969, which were not reachable from huginn), plus dev-tool patch updates.
- Test coverage excludes the generated
Clickhouse.Grpc.*modules. - New runtime dependency
:mint~> 1.11for the streaming transport. mix hex.auditacknowledges CVE-2026-43966 (cowlib, and gun through the GHSA alias) viahex: [ignore_advisories: ...]inmix.exs. No cowlib release fixes it, and the vulnerable structured-header encoder is not called by huginn or any of its dependencies; the rationale is documented next to the entry. The findings still print under "Ignored advisories".
CI
- New jobs: a dependency audit (
hex.audit,deps.auditvia mix_audit, unused-lock check) and the ClickHouse integration suite. Actions are pinned to commit SHAs and the workflow token is read-only. - Releases publish only after the full CI suite passes, and only when the tag
matches
@versioninmix.exs; the tag no longer rewrites the version.HEX_API_KEYmoves to thehexGitHub environment.
0.5.0 - 2026-08-29
Breaking
ssl: truenow verifies the peer certificate. It previously sentssl: [], which is truthy and so overrode the connection pool's own verifying default, leavingverifyunset —verify_noneon OTP < 26. A connection to a server with a self-signed or otherwise untrusted certificate that used to succeed will now fail during the TLS handshake. That is the point, but it is a visible break. To keep connecting, supply the trust chain explicitly:ssl: [verify: :verify_peer, cacertfile: "/path/to/ca.pem"].insert_stream/3now honours:formatand:chunk_size. Both were previously ignored: every element of the enumerable was sent verbatim asinput_data, so structured rows raisedProtobuf.EncodeErrorand neither option had any effect. Elements that are already binaries are still concatenated verbatim, soFile.stream!/2pipelines are unaffected. If you pass structured rows, make sure the SQLFORMATclause matches:format(which defaults to"TabSeparated") — a mismatch is now a ClickHouse parse error rather than a silent no-op.stream_query/2now emits{:error, reason}instead of ending empty. On a connection failure it previously produced an empty stream, indistinguishable from an empty result set. Consumers that match only{:ok, result}will now raise on the error element instead of silently observing zero rows.
Changed
- Upgraded to gRPC 1.0.
grpc_connection_pool ~> 0.5.2, which bringsgrpc 1.0.4(client/server split into separate packages) andgrpc_core 1.0.4. Huginn's application module no longer startsGRPC.Client.Supervisor: as of grpc 1.0 the:grpcapplication supervises client connections itself, and the old child spec referenced a module that no longer exists, so the application could not boot. - Regenerated the ClickHouse protobuf bindings from ClickHouse
masterwithprotoc-gen-elixir0.17.0.LogsLevelgainsLOG_TEST(mapped to:test), and the generated file now lives atlib/huginn/proto/clickhouse/grpc/clickhouse_grpc.pb.ex. :protobufand:jasonare now declared dependencies. grpc 1.0 no longer depends on:protobuf, and:jasonwas only ever reached transitively despite being used forJSONEachRow.Huginn.Clickhouse.Result.output_formatis nownilrather than""when the server omits it — which it does on every chunk after the first of a streaming response. Code pattern-matching on""needs updating.- Added
Huginn.Clickhouse.Result.from_grpc/2, which accepts:formatand:columnsdefaults so a streaming consumer can decode a later chunk with the metadata established by the first one.from_grpc/1is unchanged.
Fixed
stream_query/2silently dropped most rows of a large result. ClickHouse setsoutput_format/output_columnsonly on the firstResultof a stream; every later chunk was therefore parsed with an unknown format and collapsed into a single opaque row. A 200,000-row query returned 65,412 rows. The format and columns from the first chunk are now carried forward, and the gRPC stream is enumerated exactly once instead of being restarted per chunk.stream_query/2swallowed connection failures, returning an empty stream instead of an{:error, reason}item.insert_stream/3ignored its documented:formatand:chunk_sizeoptions, passing each element straight intoinput_data; structured rows raisedProtobuf.EncodeError. It now encodes and chunks viaHuginn.Clickhouse.Stream.input_stream/3, which also terminates every row with a newline so adjacent chunks cannot merge rows.input_stream/3re-enumerated its source once per chunk (Enum.drop+Enum.any?lookahead), which was quadratic and re-ran side effects for non-restartable sources such asFile.stream!/2.- Retries never fired for an unavailable pool.
:not_connected, the only errorGrpcConnectionPool.get_channel/1returns, was missing from the transient set. - A trailers-only gRPC reply (
grpc-status 0with no message) raised aFunctionClauseErrorinstead of returning{:error, {:unexpected_reply, _}}.
0.4.0 - 2026-06-06
Added
- Telemetry instrumentation.
query/2,insert/3, andinsert_stream/3now emit[:huginn, :query, :start | :stop | :exception]span events with metadata (:method,:sql,:query_id,:pool, and:rows/:statson stop). SeeHuginn.Clickhouse.Telemetry. - Built-in default logger.
Huginn.attach_default_logger/1/detach_default_logger/0attach a ready-madeLoggerhandler for the telemetry events. Off by default. - Opt-in retries.
query/2andinsert/3accept:retriesand:retry_backoffoptions to retry transient transport failures (connection errors, gRPCUNAVAILABLE/DEADLINE_EXCEEDED) with exponential backoff. ClickHouse query errors are never retried. SeeHuginn.Clickhouse.Retry. Huginn.Clickhouse.SQL.escape/1for safe single-quoted string literals.Result.parse_output/3, a column-aware variant ofparse_output/2.
Fixed
- Streaming insert (
insert_stream/3) actually works now. It was calling the client-streaming gRPC stub incorrectly (passing the request enumerable as the options argument), so no data was ever sent. It now opens the stream, pushes eachQueryInfowithGRPC.Stub.send_request/3(settingnext_query_infocorrectly and emitting a final END_STREAM frame), and reads the reply withrecv/2. Verified end-to-end against a live ClickHouse. - Bidirectional streaming (
stream_io/1) actually works now. Same underlying stub-call bug, plus the gRPC stream is now driven from a single owner process (gun delivers all stream messages to one process), so sending and consuming replies no longer dead-locks. Verified end-to-end. - CSV parsing now correctly handles quoted fields containing commas,
embedded quotes (
""), and is symmetric with the library's CSV writer. Previously a naive comma split corrupted such rows. JSONEachRowresults now extract values in column order instead of relying on JSON object key order, which could misalign values with columns.- SQL string escaping in
cancel/2now escapes backslashes before quotes, so aquery_idcontaining a trailing backslash can no longer break out of the string literal. stream_io/1now returns{:error, reason}when a channel cannot be acquired instead of raising aMatchErrorin the caller.
Changed
- Upgraded
grpc_connection_poolto~> 0.4.0(from~> 0.2.1). The 0.4.x line is a rewrite with an ETS/atomics zero-GenServer hot path and pluggable selection strategies;Huginn.Clickhouse.Config.to_pool_config/1'sendpoint:/pool:keyword output remains compatible, so no application changes were required. - Public functions now read the application config once per call instead of twice (no behavior change).
cancel_where/2documents that its condition is interpolated verbatim and must come from trusted input only.
Tooling
- Added GitHub Actions CI (
compile --warnings-as-errors,format,credo,test,dialyzer). - Added a tag-triggered release workflow that publishes to Hex on
v*tags (requires aHEX_API_KEYrepository secret). - Added Credo (
.credo.exs) and Dialyzer (dialyxir) to the toolchain. - Added
:telemetryas a direct dependency; bumpedex_docto~> 0.34. - Added an integration test suite (tagged
:integration, excluded by default; run withmix test --include integrationagainst the docker-compose ClickHouse) covering the request/response and streaming paths end-to-end.
0.3.0 - 2025
- Initial public release on Hex: ClickHouse gRPC client supporting all four
ClickHouse gRPC methods (
ExecuteQuery,ExecuteQueryWithStreamInput,ExecuteQueryWithStreamOutput,ExecuteQueryWithStreamIO), connection pooling, password/JWT auth, query cancellation, and result parsing.