Skip to content

Extract conversion functions in FunctionsConversion.h#97704

Merged
Algunenano merged 6 commits intoClickHouse:masterfrom
Algunenano:conversion_wip
Feb 24, 2026
Merged

Extract conversion functions in FunctionsConversion.h#97704
Algunenano merged 6 commits intoClickHouse:masterfrom
Algunenano:conversion_wip

Conversation

@Algunenano
Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Extract conversion functions in FunctionsConversion.h

This should be purely a refactor into smaller functions in order to not have a huge, not optimizable, loop constexpr functions. It will allow introducing further optimizations (some dynamic dispatch at least) and in any case the code should be clearer.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh Bot commented Feb 23, 2026

Workflow [PR], commit [7d30185]

Summary:

@clickhouse-gh clickhouse-gh Bot added the pr-build Pull request with build/testing/packaging improvement label Feb 23, 2026
Algunenano and others added 5 commits February 23, 2026 12:48
Move 41 non-trivial `FunctionCast` method bodies from
`FunctionsConversion.h` into `FunctionsConversion.cpp`.

Each of the 32 `FunctionsConversion_impl*.cpp` files was spending ~13s
compiling `FunctionCast` methods defined inline in the header — this was
100% redundant since `FunctionCast` is a non-template class. Time-trace
of impl07 confirms: compile time dropped from ~30s to 4.7s, with
`FunctionCast` parsing reduced from ~13s to 0.01s. Across all 32 TUs
this eliminates ~400s of total CPU time.

Methods kept inline: constructor, trivial getters, and small static
helpers (`createFunctionAdaptor`, `createToNullableColumnWrapper`,
`createIdentityWrapper`, `createNothingWrapper`).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts:
#	src/Functions/FunctionsConversion.h
`TYPE_MISMATCH`, `CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN`, and
`SIZES_OF_ARRAYS_DONT_MATCH` were moved to the cpp file but their
declarations were left behind in the header.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…sion.h

Fix clang-tidy `readability-avoid-const-params-in-decls` errors for
`createWrapper`, `createBoolWrapper`, `createUInt8ToBoolWrapper`, and
`createFixedStringWrapper` declarations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ecute

On master, `ConvertImpl::execute` is marked `NO_SANITIZE_UNDEFINED`.
When helper functions were extracted from it, the attribute was lost,
causing UBSan to flag the previously-suppressed `static_cast` overflow
in `convertNumericGeneral`.

Restore the attribute on all extracted helpers: `convertToBool`,
`convertFromUUIDToUInt128`, `convertFromUInt128toIPv6`,
`convertFromIPv6ToUInt128`, `convertDateTimeToZero`,
`convertFromIPv6ToIPv4`, `convertFromIPv4ToIPv6`,
`convertFromUInt64ToIPv4`, `convertToUnixTimestampFromDate`,
`convertDecimal`, and `convertNumericGeneral`.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=97704&sha=662251436bb541092bf3701340a2f4a65bb4d972&name_0=PR&name_1=Stateless%20tests%20%28amd_ubsan%2C%20parallel%29

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Algunenano Algunenano added this pull request to the merge queue Feb 24, 2026
Merged via the queue into ClickHouse:master with commit e1b9ddb Feb 24, 2026
148 checks passed
@Algunenano Algunenano deleted the conversion_wip branch February 24, 2026 08:56
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 24, 2026
Algunenano added a commit to Algunenano/ClickHouse that referenced this pull request Feb 24, 2026
Add rules to catch compilation time regressions during code review:
non-trivial code in widely-included headers, heavy transitive includes
in high-fan-out headers, unnecessary template instantiations, and large
`constexpr` evaluation in headers.

Inspired by ClickHouse#97704, ClickHouse#97497, ClickHouse#97496.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rschu1ze rschu1ze added the post-approved Approved, but after the PR is merged. label Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

post-approved Approved, but after the PR is merged. pr-build Pull request with build/testing/packaging improvement pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants