Skip to content

Respect input_format_null_as_default for nulls in non-nullable Arrow fields - #127453

Merged
alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
Algunenano:arrow-null-as-default-non-nullable-field
Oct 23, 2026
Merged

alexey-milovidov merged 6 commits into
ClickHouse:masterfrom
Algunenano:arrow-null-as-default-non-nullable-field

Conversation

@Algunenano

@Algunenano Algunenano commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Related: #106522
Related: #111996

The native Arrow/ArrowStream reader, the default since 26.7 and the only one since 26.8, rejects a field that the schema declares non-nullable but whose batch contains nulls (Arrow IPC field '...' is declared non-nullable but its FieldNode reports N nulls). Producers such as pyarrow write such data without complaint, and the Apache Arrow library reader read those nulls as NULLs, so input_format_null_as_default turned them into defaults. After upgrading to 26.8, users relying on this saw all their inserts fail, with no setting to restore the old behavior.

Such fields are now read as NULL, as the library reader did: top-level columns, dictionary-encoded columns, and children of lists, structs and maps. The column is decoded from a copy of its field that declares those fields nullable, so the types derived from the schema stay consistent with the decoded columns. The conversion to the requested type then applies the usual rules: with input_format_null_as_default = 1 the nulls become the column DEFAULT expression or the type default for a non-nullable target; with 0 they raise CANNOT_INSERT_NULL_IN_ORDINARY_COLUMN; a Nullable target gets NULL either way.

Nulls in non-nullable children of union alternatives and of dictionary values are still rejected with INCORRECT_DATA. Reading them as NULL would make the decoded type depend on each batch's nulls, which Variant conversion and delta dictionary merging can't handle. The library reader did not support these types either.

The rejection was added in #106522 because null rows of a non-nullable field were decoded from undefined value bytes. That no longer happens: a non-zero null count requires a correctly sized validity bitmap regardless of the declared nullability, and null rows are masked before values are decoded.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

The Arrow and ArrowStream input formats again read nulls in fields declared non-nullable as NULLs instead of rejecting the data, so they are converted to default values when input_format_null_as_default is enabled (the default). This restores the behavior of the Apache Arrow library reader that was removed in 26.8.


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

Version info

  • Merged into: 26.11.1.676-master (included in 26.11 and later)
  • Backported to: 26.10.3.5, 26.9.26.17, 26.8.35.15

@clickhouse-gh

clickhouse-gh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [984cadf]

Summary: ✅


AI Review

Summary

Restores reading nulls from non-nullable Arrow and ArrowStream fields so destination conversion can preserve NULLs, apply defaults, or reject them. No actionable findings remain at 984cadfd200a20aad4033fb62803403ab1199a03; the earlier dictionary, union, and map findings are addressed in the current code.

Missing context / blind spots
  • ⚠️ Focused local checks passed for both formats using the CI binary at 73687071c5ddc073e7147719414713c589359894, covering scalar and dictionary nulls, nested collections, nullable tuples, map values, and strict/default conversion. The final map-entry/key rejection changes were verified in source and against their regression fixtures, but were not executed locally. A passing current-head run of 05443_arrow_null_as_default_non_nullable_field would close that execution gap; the maintainer reports that it passes locally in the existing review thread.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 22, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 22, 2026
@alexey-milovidov alexey-milovidov added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Oct 22, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). label Oct 22, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 984cadfd2 with master 68d2bfb07 (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

5 object files changed (+25.17 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Processors/Formats/Impl/ArrowIPC/RecordBatchDecoder.cpp.o 617.65 KiB 641.75 KiB +24.10 KiB (+3.90%)

719 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

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

Job report

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=127453&sha=73687071c5ddc073e7147719414713c589359894&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. It is unrelated to this PR (repeated UNKNOWN_IDENTIFIER from MutatePlainMergeTreeTask in the upgrade check) and matches #120975, with a candidate fix in #125293.

@groeneai

Copy link
Copy Markdown
Collaborator

Same signature as #120975: all 177 lines in upgrade_error_messages.txt are test_5.t_stale_part_type_5, part all_1_1_1 (the empty part that DETACH PART leaves in 04653, loaded as active after the restart). The previous release in this run was v26.9.25.15-stable.

The fix in progress is #125293 by @ tiandiwonder: test-only, old_parts_lifetime = 0 on that table. CI is green, it is mergeable, and it has no review yet. I validated it on a v26.9.22.3 server restarted into master: 42 errors become 0 (#125827 (comment)).

Merging it to master alone will not clear this check, because the Upgrade check runs the previous release's copy of 04653. It also needs v26.9-must-backport, plus v26.10-must-backport for when 26.10 becomes the previous release. The 04653 files are identical on master, 26.10 and v26.9.25.15-stable, so both cherry-picks apply cleanly. 26.9 is tagged daily, so the first tag after the backport fixes this check on every PR. I can't approve or add labels on this repo.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thanks, @groeneai. The Upgrade check failure is unrelated to this PR; it will be tracked via #120975 and fixed by #125293 (with v26.9-must-backport / v26.10-must-backport labels, which needs a maintainer). No changes needed in this PR.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 23, 2026
Merged via the queue into ClickHouse:master with commit ccc3eef Oct 23, 2026
178 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 23, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 23, 2026
robot-clickhouse-ci-1 added a commit that referenced this pull request Oct 25, 2026
Cherry pick #127453 to 26.8: Respect input_format_null_as_default for nulls in non-nullable Arrow fields
robot-clickhouse added a commit that referenced this pull request Oct 25, 2026
robot-clickhouse-ci-1 added a commit that referenced this pull request Oct 25, 2026
Cherry pick #127453 to 26.9: Respect input_format_null_as_default for nulls in non-nullable Arrow fields
robot-clickhouse added a commit that referenced this pull request Oct 25, 2026
robot-clickhouse-ci-1 added a commit that referenced this pull request Oct 25, 2026
Cherry pick #127453 to 26.10: Respect input_format_null_as_default for nulls in non-nullable Arrow fields
robot-clickhouse added a commit that referenced this pull request Oct 25, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 25, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 25, 2026
Backport #127453 to 26.10: Respect input_format_null_as_default for nulls in non-nullable Arrow fields
clickhouse-gh Bot added a commit that referenced this pull request Oct 25, 2026
Backport #127453 to 26.8: Respect input_format_null_as_default for nulls in non-nullable Arrow fields
clickhouse-gh Bot added a commit that referenced this pull request Oct 25, 2026
Backport #127453 to 26.9: Respect input_format_null_as_default for nulls in non-nullable Arrow fields
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

6 participants