Skip to content

Backport #90880 to 25.10: Add setting for compatibility serialziation of string - #91322

Merged
clickhouse-gh[bot] merged 2 commits into
25.10from
backport/25.10/90880
Dec 5, 2025
Merged

clickhouse-gh[bot] merged 2 commits into
25.10from
backport/25.10/90880

Conversation

@robot-clickhouse

Copy link
Copy Markdown
Member

Original pull-request #90880
Cherry-pick pull-request #91302

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

The PR source

The PR is created in the CI job

@robot-clickhouse robot-clickhouse added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default labels Dec 2, 2025
@clickhouse-gh

clickhouse-gh Bot commented Dec 2, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [f545c10]

@antonio2368
antonio2368 requested a review from Copilot December 5, 2025 08:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This backport adds a new setting serialize_string_in_memory_with_zero_byte to maintain compatibility when querying clusters with mixed ClickHouse versions. The setting controls whether String values are serialized with a trailing zero byte during aggregation operations, allowing older and newer versions to communicate correctly.

Key changes:

  • Adds serialize_string_in_memory_with_zero_byte setting (default: true) for backward compatibility
  • Threads serialization settings through aggregation and column serialization paths
  • Updates all column serialization/deserialization methods to accept optional settings parameter
  • Includes integration tests verifying cross-version compatibility

Reviewed changes

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

Show a summary per file
File Description
src/Core/Settings.cpp Adds the new boolean setting with documentation
src/Core/SettingsChangesHistory.cpp Registers setting in version history for 25.8 and 25.10
src/Columns/IColumn.h Introduces SerializationSettings struct and updates method signatures
src/Columns/ColumnString.cpp Implements conditional zero-byte serialization based on setting
src/Columns/ColumnUnique.h Handles deserialization adjustment for zero-byte handling
src/Common/ColumnsHashing.h Propagates settings through hash method context
src/Interpreters/Aggregator.h Adds setting to aggregator parameters
src/Interpreters/AggregationMethod.cpp Updates all aggregation method implementations
tests/integration/test_string_aggregation_compatibility/test.py Integration tests for cross-version compatibility
Multiple column implementations Updates serialization signatures across all column types

{"distributed_cache_receive_timeout_ms", 3000, 3000, "New setting"},
{"distributed_cache_send_timeout_ms", 3000, 3000, "New setting"},
{"distributed_cache_tcp_keep_alive_timeout_ms", 2900, 2900, "New setting"},
{"serialize_string_in_memory_with_zero_byte", true, true, "New setting"},

Copilot AI Dec 5, 2025

Copy link

Choose a reason for hiding this comment

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

Corrected spelling of 'serialziation' to 'serialization' in PR title.

Copilot uses AI. Check for mistakes.
throw Exception(ErrorCodes::ATTEMPT_TO_READ_AFTER_EOF, "Not enough data to deserialize string value in ColumnUnique.");

size_t ret = uniqueInsertData(in.position(), string_size);
size_t ret = uniqueInsertData(in.position(), string_size - serialize_string_with_zero_byte);

Copilot AI Dec 5, 2025

Copy link

Choose a reason for hiding this comment

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

Subtracting a boolean from string_size to adjust for the zero byte is fragile. If serialize_string_with_zero_byte is true (non-zero), this computes string_size - 1, which is correct. However, explicitly using a ternary operator would make the intent clearer and avoid potential issues if the boolean is somehow not 0 or 1. Consider: string_size - (serialize_string_with_zero_byte ? 1 : 0) or adding a comment explaining the boolean-to-int conversion.

Suggested change
size_t ret = uniqueInsertData(in.position(), string_size - serialize_string_with_zero_byte);
size_t ret = uniqueInsertData(in.position(), string_size - (serialize_string_with_zero_byte ? 1 : 0));

Copilot uses AI. Check for mistakes.
@clickhouse-gh
clickhouse-gh Bot merged commit b94b135 into 25.10 Dec 5, 2025
@clickhouse-gh
clickhouse-gh Bot deleted the backport/25.10/90880 branch December 5, 2025 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants