Skip to content

Keep enum names when merge unifies different enums - #127583

Open
evillique wants to merge 8 commits into
ClickHouse:masterfrom
evillique:merge-enum-inference-to-string
Open

evillique wants to merge 8 commits into
ClickHouse:masterfrom
evillique:merge-enum-inference-to-string

Conversation

@evillique

@evillique evillique commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

merge, and Merge tables without a column list, turned a column that has different enums in different tables into the underlying integer. The values lost their names, and if the tables numbered the enums differently, the same number meant different names in different rows. Now such a column becomes an enum with the names of all tables if the numbering is consistent, and LowCardinality(String) if it conflicts, so each table is read by name. The new setting merge_table_keep_enum_names controls this, and compatibility with an earlier version restores the integer type.

Related: #127195

Changelog category (leave one):

  • Backward Incompatible Change

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

The merge table function and Merge tables without a column list keep enum names when the tables have different enums in a column: they infer an enum with the names of all tables if the numbering is consistent, and LowCardinality(String) if it conflicts, instead of the underlying integer. To get the previous behavior, set merge_table_keep_enum_names to never or compatibility to 26.10.


Workflow [PR]
Sync PR [sync-upstream/pr/127583]

@clickhouse-gh

clickhouse-gh Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7c9ddd6]

Summary: ✅


AI Review

Summary

Reviewed #127583 at 7c9ddd60ce8e21f9f9cd2f5b331efb29ca10c91b, including all prior discussion. The change preserves enum names during merge and schema-less Merge inference, combines consistently numbered enums, and uses LowCardinality(String) for conflicting definitions. No actionable findings remain; the five previous findings are addressed in the current code.

Consumer tracing covered:

  • TableFunctionMerge::getActualTableStructure and the StorageMerge constructors: both inference entrypoints carry the revised types and column descriptions.
  • getModifiedQueryInfo and convertAndFilterSourceStream: source aliases are evaluated before conversion, including dependent aliases and map subcolumns.
  • supportedPrewhereColumns and getQueryProcessingStage: type mismatches restrict predicate pushdown and order-sensitive delegated processing.
  • addMissingDefaults, subcolumn extraction, pipeline union, and parallel-replica expansion: these paths consume defaults or converted headers rather than assuming the previous integer representation.

Seven focused SQL checks passed using the PR-head fast-test binary. The new regression's output exactly matched its reference. Additional checks covered compatibility = '26.10', direct and transitive aliases through both inference entrypoints, explicit and optimized map subcolumns, consistent enum extensions, missing columns, and mixed enum/integer sources.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 23, 2026
Comment thread src/Core/Settings.cpp Resolved
Comment thread src/Storages/StorageMerge.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-storage-merge Merge table engine (logical union over tables) and related mechanics. label Oct 23, 2026
Comment thread src/Storages/StorageMerge.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 7c9ddd60c with master eb5cbd890 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

79 object files changed (+111.00 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/StorageMerge.cpp.o 1.58 MiB 1.65 MiB +74.48 KiB (+4.60%)
src/CMakeFiles/dbms.dir/Core/SettingsEnums.cpp.o 2.47 MiB 2.49 MiB +24.25 KiB (+0.96%)

711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

1210 translation units recompiled, 10656 s compile time in total, 1210 of them have a recent master baseline.

Job report

@evillique evillique changed the title Infer LowCardinality(String) in merge for enums with conflicting numbering Keep enum names when merge unifies different enums Oct 23, 2026
@clickhouse-gh clickhouse-gh Bot added pr-backward-incompatible Pull request with backwards incompatible changes and removed pr-bugfix Pull request with bugfix, not backported by default labels Oct 23, 2026
Comment thread src/Storages/StorageMerge.cpp Resolved
Comment thread src/Storages/StorageMerge.cpp Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-storage-merge Merge table engine (logical union over tables) and related mechanics. pr-backward-incompatible Pull request with backwards incompatible changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant