Skip to content

Generate query id on client side if not set#116

Merged
alex-clickhouse merged 2 commits intomainfrom
query_id
Dec 8, 2025
Merged

Generate query id on client side if not set#116
alex-clickhouse merged 2 commits intomainfrom
query_id

Conversation

@alex-clickhouse
Copy link
Copy Markdown
Collaborator

No description provided.

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ClickHouse.Driver/ADO/ClickHouseCommand.cs 88.88% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes the query ID generation from server-side to client-side by automatically generating a GUID when no query ID is explicitly set. Previously, ClickHouse server would generate the query ID; now the driver generates it before sending the request.

Key changes:

  • Client-side GUID generation for query IDs when not explicitly provided
  • Caching mechanism to ensure consistent query ID per request
  • Updated documentation and examples to reflect the new behavior

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
examples/Advanced_001_QueryIdUsage.cs Updated comments to reflect client-side GUID generation instead of server-side
ClickHouse.Driver/ClickHouseUriBuilder.cs Added GetEffectiveQueryId() method with caching logic and auto-GUID generation
ClickHouse.Driver/ADO/ClickHouseCommand.cs Refactored to use effective query ID earlier in execution flow and updated logging
ClickHouse.Driver.Tests/Misc/UriBuilderTests.cs Added comprehensive tests for query ID generation, caching, and uniqueness
ClickHouse.Driver.Tests/ADO/ConnectionTests.cs Enhanced tests to verify GUID format and added test cases for empty string and uniqueness
Comments suppressed due to low confidence (1)

ClickHouse.Driver/ADO/ClickHouseCommand.cs:1

  • After the uriBuilder is created and the effective query ID is generated, the QueryId property of ClickHouseCommand is never updated with the auto-generated value. Users checking command.QueryId after execution will see null instead of the GUID that was actually used. Consider adding QueryId = uriBuilder.GetEffectiveQueryId(); after line 177 to populate the property with the effective value.
using System;

Comment thread ClickHouse.Driver/ADO/ClickHouseCommand.cs
Comment thread ClickHouse.Driver/ADO/ClickHouseCommand.cs
@alex-clickhouse alex-clickhouse merged commit 3d85ffc into main Dec 8, 2025
15 checks passed
@alex-clickhouse alex-clickhouse deleted the query_id branch December 8, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants