Skip to content

Validate ColumnArray element types before appending - #554

Open
fallintoplace wants to merge 3 commits into
ClickHouse:masterfrom
fallintoplace:fix/validate-array-append
Open

Validate ColumnArray element types before appending#554
fallintoplace wants to merge 3 commits into
ClickHouse:masterfrom
fallintoplace:fix/validate-array-append

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Validate the nested column type before ColumnArray::AppendAsColumn() changes offsets.
  • Keep the existing compatible append cases for tuple field names, LowCardinality, Bool/UInt8, and nested arrays.
  • Preserve ColumnDateTime timezone metadata through Slice() and CloneEmpty().
  • Add regression tests for wrong types, unchanged state, empty columns, compatible cases, and timezone-qualified arrays.

Why?

Append() can silently ignore an incompatible column. AppendAsColumn() still adds the source size to offsets after that. The array can then report rows that are not present in nested data and the native stream can get out of sync.

This checks the type first and throws ValidationError before nested data or offsets are changed. The DateTime metadata fix keeps same-type arrays compatible when Append() slices their rows.

Tests

  • cmake --build build --target clickhouse-cpp-ut -j 8
  • ./build/ut/clickhouse-cpp-ut --gtest_filter='ColumnArray.*:ColumnArrayT.*:ColumnsCase.*:ColumnLowCardinality.*'

Related to #543

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.

1 participant