Skip to content

Parquet v3: materialize constant column chunks from statistics - #2976

Draft
ianton-ru wants to merge 33 commits into
antalya-26.8from
feature/antalya-26.8/parquet-constant-columns
Draft

ianton-ru wants to merge 33 commits into
antalya-26.8from
feature/antalya-26.8/parquet-constant-columns

Conversation

@ianton-ru

Copy link
Copy Markdown

Part of #2181 (Parquet v3 reader). A Parquet column chunk whose min/max statistics are equal, or that is entirely null, is returned as a constant (ColumnConst) instead of being read and decoded. When the Column Index is available, row subgroups that are single-valued according to it are handled the same way. input_format_parquet_use_column_index_for_constant_columns forces the Column Index load for this purpose; it is off by default.

The optimization is not applied while input_format_parquet_verify_checksums is enabled, which is its default. The data pages of a constant chunk are not read, so their checksums would not be verified; with verification on, such chunks are decoded normally. In effect the optimization is active only when verification is disabled. This keeps the page-level checksum check, covered by 03408_parquet_checksums, from being skipped silently.

Settings:

  • input_format_parquet_use_constant_column_optimization (default on; effective only with verification disabled)
  • input_format_parquet_use_column_index_for_constant_columns (default off)
  • input_format_parquet_fill_constant_pages (experimental, default off)

Design notes: docs/design/parquet-v3-page-level-constant-column.md.

Related: #2181

Changelog category (leave one):

  • Performance Improvement

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

Parquet v3 reader: a column chunk whose statistics show a single value, or only nulls, is materialized from the statistics without reading its data pages. This applies only when input_format_parquet_verify_checksums is disabled.

Documentation entry for user-facing changes

The settings are documented in their declarations (input_format_parquet_use_constant_column_optimization, input_format_parquet_use_column_index_for_constant_columns, input_format_parquet_fill_constant_pages). The design notes are in docs/design/parquet-v3-page-level-constant-column.md.

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • Aarch64 tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • CAS (content-addressed storage; Antalya only)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • OAuth (5m)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

UnamedRus and others added 20 commits November 30, 2026 13:22
When a Parquet column chunk provably holds a single value in every row -
its min/max statistics have `min_value == max_value`, no nulls, and the
value is exact - the reader no longer fetches or decodes that chunk's
data pages. Instead `detectConstantColumn` records the value and
`decodePrimitiveColumn`/`formOutputColumn` materialize it directly.

This skips the offset index, column index, dictionary page and data page
reads for such chunks (the row group already passed the key condition via
its `min == max` hyperrectangle), which is a byte-level I/O win for wide
constant columns, plus the decode/decompression CPU.

Restricted to flat, top-level primitive columns with no element nulls.
For `BYTE_ARRAY`/`FIXED_LEN_BYTE_ARRAY` the writer may truncate min/max,
so `min == max` is trusted only when `is_min_value_exact` and
`is_max_value_exact` are both set; fixed-width numeric types are never
truncated.

The value is taken from `PageDecoderInfo::decodeField`, which yields it
in the final output (post-cast) domain - e.g. `DateTime` written as
`TIMESTAMP_MILLIS` decodes to seconds, not the raw millisecond
`decoded_type`. So the constant is materialized directly in the output
type, bypassing the `decoded_type` column and `castColumn`.

Gated by the new setting
`input_format_parquet_use_constant_column_optimization` (default on). A
new `ParquetConstantColumnChunks` ProfileEvent counts materialized
chunks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two gate bugs made detectConstantColumn reject every column, so the
optimization never triggered on real files. Found by building and testing
against CH-written Parquet.

1. Null gate. The CH writer omits `null_count` for physically non-nullable
   (`REQUIRED`) columns, but the gate required `null_count` to be present
   and zero, rejecting every non-nullable column. A `REQUIRED` column can
   have no nulls regardless of the statistic, so only require zero
   `null_count` when the column is physically nullable (max definition
   level > 0).

2. Structural gate. `levels[0]` is a synthetic root sentinel with
   `is_array = true`, so a flat `REQUIRED` column's `levels.back()` IS that
   root (`size() == 1`, `is_array == true`) and a `Nullable` column has
   `size() == 2`. The old `levels.size() == 1 && !levels.back().is_array`
   test therefore rejected exactly the flat columns it meant to accept.
   Replace with the correct flatness signals (`levels.back().rep == 0` and
   `max_array_def == 0`), keep the `group_nullable` exclusion, and require
   the output column to be primitive (top-level, not a Tuple/Map/Array
   leaf) via `output_columns`.

Verified on a CH-written file (1M rows, constant Int64/String/DateTime/
Nullable columns): the optimization now fires (`ParquetConstantColumnChunks`
= columns x row groups), results are correct (including the
TIMESTAMP_MILLIS -> DateTime seconds path), reading the constant columns
drops `ParquetPrefetcherReadRandomRead` 10 -> 1 and `ParquetDecodingTasks`
96 -> 64, and a varying column is correctly not treated as constant.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extends the constant-column optimization to the all-null case. When a
Parquet column chunk provably holds only nulls - its `null_count` statistic
equals `num_values` on a physically nullable leaf - the reader no longer
fetches or decodes that chunk's dictionary or data pages. `detectConstantColumn`
marks the chunk constant (and `is_all_null`), and `formOutputColumn`
materializes the result directly: `Null` for a Nullable output, or the output
default when `input_format_null_as_default` substitutes nulls for a
non-nullable output. A non-nullable output without null substitution cannot
represent the result, so such a chunk is left to the normal decode path.

Unlike the single-value case this needs no value decode, so it sidesteps the
min/max exactness and `BYTE_ARRAY` truncation checks entirely; it only reads
the `null_count` count. `formOutputColumn` records every row of an all-null
chunk in `block_missing_values` (the single-value case has no nulls and records
nothing), matching the normal decode path's null-map bookkeeping so
`input_format_null_as_default` stays correct.

All-null wide chunks are common in schema-evolved files (a column added later
is all-null in older row groups), so this skips dictionary, data page, offset
index and column index reads for a frequent real-world shape. Reuses the
existing `input_format_parquet_use_constant_column_optimization` setting and
the `ParquetConstantColumnChunks` ProfileEvent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
formOutputColumn previously expanded a constant column chunk with
insertMany(Field, num_rows) - an O(rows) per-row Field-dispatch fill that
showed up as a consistent ~20% UserTime increase in profiling (the baseline
decoded the same near-constant chunk cheaply via RLE/dictionary).

Emit a ColumnConst instead: O(1) to build, and the const-ness propagates
through the pipeline. A PREWHERE/WHERE predicate computes its result from the
value without expanding the stored column, and GROUP BY / aggregation over the
column get a const key. The value is already in the output (post-cast) domain.
The all-null block_missing_values bookkeeping is unchanged.

The reader path preserves the const: getOrFormOutputColumn returns it as-is,
ColumnConst::size() == rows_pass satisfies the delivery checks, and
ColumnConst::filter keeps it const through multistage PREWHERE.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
Extends the constant-column optimization from whole-chunk (tier 1, footer
statistics) to per-row-subgroup granularity using the Column Index per-page
min/max/null_pages, which the reader already loads for predicate push-down.
Catches columns constant over a run of pages without the whole row group being
constant (common in sorted/clustered data), with no change to subgroup/chunk
sizing.

- constColumnMaterializationEligible: shared flat-top-level-primitive gate,
  factored out of detectConstantColumn.
- applyColumnIndex: retain per-page constant info (value / is_const / all_null)
  in ColumnChunk::page_const_info. Fixed-width numeric/date/time only for value
  constants (the Column Index has no per-page exactness flag, so a truncated
  BYTE_ARRAY min==max is untrustworthy); all_null is a plain flag, always safe.
- detectConstantSubchunk: a column is constant for a subgroup iff every page
  overlapping the subgroup row range is all-null, or all hold the same value.
- Wired into intersectColumnIndexResultsAndInitSubgroups; sets the subchunk
  constant fields so decodePrimitiveColumn skips decode and formOutputColumn
  materializes a ColumnConst. New ParquetConstantColumnSubchunks ProfileEvent.

Tier 1 stays the always-on baseline and the only detector for BYTE_ARRAY. Tier 2
is opportunistic: only where the Column Index is already loaded (predicate
push-down columns), never force-fetched.

Deferred (follow-up): skipping the prefetch of constant subgroups pages (the I/O
win). Currently those pages are still fetched and skipped forward by the next
subgroups skipToRowOrNextPage; correct but does not yet save the read.

Design: docs/design/parquet-v3-page-level-constant-column.md

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
Completes tier-2: a per-subgroup constant column (detectConstantSubchunk) now
also skips fetching its data pages, not just decoding them. In
determinePagesToPrefetch, a constant subchunk claims no pages; a page fully
inside it is released (never fetched), while a page shared with a neighbouring
non-constant subgroup is left for that subgroup to claim.

Safe because tier 2 only exists when the Column Index (hence Offset Index) is
loaded: a constant subgroup never calls skipToRowOrNextPage, and a non-constant
subgroup jumps directly via the offset index to its own claimed pages, so a
released constant page between them is never accessed. The whole-chunk
data_pages_prefetch is still split (likely_to_be_used=false), so only claimed
pages are actually read.

This turns the tier-2 CPU/memory win into an I/O win as well (fewer S3 GETs /
ParquetPrefetcherReadRandomRead), matching tier 1 but at page granularity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
Adds input_format_parquet_use_column_index_for_constant_columns (default off).
By default tier-2 per-subgroup constant detection only runs where the Column
Index is already loaded (columns with a predicate). This setting force-loads the
Column Index (and Offset Index) for eligible read columns without a predicate,
so tier-2 can skip single-valued page runs on them too - worthwhile for sorted /
low-cardinality columns, at the cost of a small extra (tail-contiguous,
coalesced) index read.

A force-loaded column takes the same load path as a predicate column
(use_column_index = true); applyColumnIndex records per-page constant info but
skips page-level predicate pruning when the column has no condition (prev_row_idx
stays 0 -> whole chunk selected -> no restriction).

Setting is declared in FormatFactorySettings, plumbed through FormatSettings /
FormatFactory, and recorded in SettingsChangesHistory (26.6).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
…off]

Approach B: when only PART of a row subgroup is single-valued (a constant run
shorter than, or straddling, a subgroup), fill those pages from the per-page
Column Index while decoding only the varying pages - producing a full column
where whole-subgroup tier-2 cannot make a ColumnConst.

Gated behind input_format_parquet_fill_constant_pages (default off). Additional
gates keep it correct and simple:
- output column must not need a post-decode cast (we fill the decoded_type
  column with the Column Index value, valid only when decoded == output value
  type);
- no predicate on the column (so no page pruning; data_pages == all pages);
- no prewhere filtering in the subgroup (avoids filter/range intersection);
- at least one single-value page and no all-null page in the subgroup (all-null
  pages fall back to the standard decode).

fillConstantPagesAndDecodeRest walks the subgroup page by page: a single-value
page is filled via insertMany (+ null-map zeros) without reading it; a varying
page is decoded with the existing skipToRowOrNextPage + readRowsInPage, which
jumps over the filled pages via the offset index without loading them.

First cut is decode-fill only: constant pages are still prefetched (correct,
some wasted I/O). Skipping their prefetch needs cross-subgroup coordination and
is a follow-up.

Design: docs/design/parquet-v3-page-level-constant-column.md

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
Completes the mixed-topology fill (input_format_parquet_fill_constant_pages,
default off): a subgroup that fills its single-value pages from the Column Index
no longer prefetches them. determinePagesToPrefetch consults
willFillConstantPages (the same deterministic predicate the decode path uses) and,
for a fill subgroup, does not claim its is_const pages - so a page overlapped
only by fill subgroups is released and never read, while a page also decoded
normally by another subgroup is still fetched.

Also adds a no-prewhere / no-row-level-filter gate to willFillConstantPages so
rows_pass == rows_total holds identically at prefetch time and decode time,
keeping the two decisions consistent.

This turns the mixed-topology fill from a decode-CPU-only win into an I/O win
too (fewer page reads), matching tier-2 at sub-subgroup granularity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
min_value == max_value provably means a single exact value for every physical
type, including BYTE_ARRAY / FIXED_LEN_BYTE_ARRAY. Statistics and Column Index
bounds are always valid (min_value <= every value <= max_value) and truncation
only ever widens them, so a truncated value - or any page/chunk with two
distinct values - yields min_value < max_value. Equality therefore requires a
single value short enough to be stored exactly; the is_*_value_exact flags are
implied and, for the Column Index (which has no per-page exact flag), never
needed.

Remove the BYTE_ARRAY/FIXED_LEN exclusion from tier 1 (detectConstantColumn) and
the per-page recording in tier 2 (applyColumnIndex), so constant string columns
and string constant page runs get the optimization too. Also fixes tier 1 for
writers that omit is_*_value_exact (previously any such BYTE_ARRAY constant was
skipped even when short and exact).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
Previously a mixed-topology subgroup (input_format_parquet_fill_constant_pages)
bailed to normal decode if any overlapping page was all-null. Now fill them too:
an all-null page appends no non-null values and marks its rows null in the null
map; the existing expand() + Nullable-wrap / null_as_default tail finalizes them
exactly as the normal decode does (the column holds compact non-null values, the
null map covers all rows). determinePagesToPrefetch also skips prefetching
all-null pages, matching the fill.

willFillConstantPages now accepts all-null pages as fillable, but still bails
when an all-null page is present and the output can represent neither null
(non-Nullable output) nor a default (no null_as_default) - the standard decode
raises the usual not-null error there.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
Drop the column_index_condition gate from willFillConstantPages. A page-pruning
predicate on the column (column_index_condition) is safe for the fill: subgroups
are built only over contiguous surviving row ranges, so a pruned page never
overlaps a subgroup and the fill never walks it; the prefetch-skip indexes
page_const_info by each page global position (page.meta into page_locations),
which is correct regardless of the data_pages subset. A column carrying an
actual prewhere/row-level filter is still blocked by the no-prewhere gate.

Gate 2 (output needs_cast) is intentionally left in place: whether decodeField
yields the decoded or the output value domain is ambiguous from static reading
(SchemaConverter/convertField vs the tier-1 is_constant branch), and guessing
wrong is silent wrong data. It needs a build + a needs_cast test to resolve
(and that test would also confirm tier-1/tier-2 on hint-cast columns).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
The mixed-topology fill now walks the rows that pass the filter
(row_subgroup.filter) instead of the whole subgroup range, so it works under
PREWHERE / row-level filters: it iterates passing ranges (like the standard
row-range decode) and, within each, fills constant / all-null pages for their
overlapping passing rows and decodes varying pages for the contiguous passing
sub-range. It therefore produces exactly rows_pass values for any filter, and
willFillConstantPages no longer depends on rows_pass - so the decision is
identical at prefetch time and decode time and the prefetch-skip can never drop
a page the decode needs.

Removes the no-prewhere and rows_pass == rows_total gates from
willFillConstantPages. The only remaining gate is needs_cast (build-gated; see
the decodeField value-domain question).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
formOutputColumn now builds the single-value constant in input_type and applies
the same castColumn the per-row decode uses when needs_cast is set, instead of
inserting the value straight into an output_type column and skipping the cast.

Today this is a no-op: the optimization only fires when the stats decoder needs
no value-transforming conversion (SchemaConverter gates allow_stats on that), so
input_type == output_type for every constant column. The change keeps the
constant path correct if allow_stats is ever generalized to allow transforming
casts (e.g. decimal rescale) - the constant would then go through the same cast
as the normal decode. Casting a ColumnConst is O(1) (one value) and preserves
const-ness, so no cost.

The all-null constant is synthesized in the output domain (Null / output
default) and is not cast. The mixed fill already casts via the normal path, so
it is future-safe too. The allow_stats / SchemaConverter logic is untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: UnamedRus <dtitmoav@gmail.com>
Tier-2 per-subgroup constant detection (`detectConstantSubchunk`, gated by
`input_format_parquet_use_column_index_for_constant_columns`) never fired for
required (non-nullable) columns.

`applyColumnIndex` computed `can_be_null` purely from the Column Index
`null_counts`: `!__isset.null_counts || null_counts[page] != 0`. ClickHouse's
own Parquet writer emits `null_counts` only for nullable columns (`Write.cpp`,
`has_null_count = max_def == 1 && max_rep == 0`), so for a required column
`null_counts` is absent and `can_be_null` was spuriously `true` on every page.
That disabled the per-page `is_const` branch, so `page_const_info` was never
populated and tier-2 detection never triggered - exactly for the common case of
a non-nullable constant column.

A required column (max def level 0) can never contain nulls regardless of
whether the Column Index carries `null_counts`, so fold the schema `nullable`
flag into `can_be_null`. `adjustRangeFromIndexIfNeeded` already gates its own
use on `nullable && can_be_null`, so required-column predicate-pruning behavior
is unchanged.

Verified on a real build (sha 60841f9): an otherwise identical file with a
nullable `run` column yields `ParquetConstantColumnSubchunks = 22` while the
non-nullable variant yielded 0; this is the same null_count-omission pattern
already fixed for tier-1 whole-chunk detection.

Signed-off-by: UnamedRus <dtitmoav@gmail.com>
The cherry-picked constant-column commits carried a settings history
hunk from the antalya-26.6 line, which added an unrelated `26.8` block
and the back-pressure setting. Restore the file from `antalya-26.8` and
record only the constant-column settings, in the current
`26.8.39.20001.altinityantalya` block.

Co-authored-by: Cursor <cursoragent@cursor.com>
Move the constant-column tests from 04811 and 04812 to the next free
numbers, 05815 and 05816, as add-test would assign them. The comment in
the constant-column test now says that the `c_dt` column needs a cast,
so it is decoded normally and not materialized.

Co-authored-by: Cursor <cursoragent@cursor.com>
The tests were renamed to 05815 and 05816 in the previous commit; the
old files are removed here, since the rename was staged separately.

Co-authored-by: Cursor <cursoragent@cursor.com>
A constant column chunk is materialized from its decoded value, and
the Column Index path (tier 2) relies on the same invariant: the value
is the output value only when no post-decode cast is applied. Make the
shared eligibility gate exclude columns that need a cast, so tier 1
and tier 2 agree. Decode the statistics value in the decoded type, since
the three-argument `decodeField` overload no longer exists on this
branch. A column that needs a cast, such as a `DateTime` written as
`TIMESTAMP_MILLIS`, is now read and decoded normally.

Co-authored-by: Cursor <cursoragent@cursor.com>
…fied

A constant column chunk or subchunk is materialized from footer and Column Index
statistics without reading its data pages, so page checksums (`input_format_parquet_verify_checksums`,
default true) were silently not verified for those chunks. The regression showed up in
`03408_parquet_checksums`, where a corrupted single-value column no longer reported the CRC error.

Constant detection is now disabled when verification is requested, so such chunks are decoded normally.
The optimization applies only when verification is turned off.

Update `05815_parquet_constant_column_optimization` and `05816_parquet_all_null_column_optimization`
to disable verification in their queries that exercise the optimization, and add
`05817_parquet_constant_column_checksums` covering the default and the disabled cases.
Document the interaction in `input_format_parquet_use_constant_column_optimization` and the design doc.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Workflow [PR], commit [b4b8276]

@ianton-ru ianton-ru added antalya performance Antalya Roadmap: Performance port-antalya PRs to be ported to all new Antalya releases antalya-26.8 labels Nov 30, 2026
ianton-ru and others added 4 commits November 30, 2026 17:58
… max

`min_value == max_value` proves a single value only for types with a total
order. For `Float32`/`Float64` it does not: NaN is excluded from statistics
(a chunk of `[1.0, NaN]` has `min == max == 1.0`), and `+0.0` and `-0.0`
compare equal (a page of `+0.0` has `min = -0.0`, `max = +0.0` per the spec,
but would be materialized as `-0.0`).

Skip the min/max-based constant detection for floating-point columns in both
tier 1 (`detectConstantColumn`) and tier 2 (`applyColumnIndex`). The all-null
shortcut does not depend on min/max and is kept.

Add a stateless test and update the design doc.

Co-authored-by: Cursor <cursoragent@cursor.com>
… rules out nulls

When the footer `null_count` is zero for a nullable column, no null map is
allocated (`need_null_map` is false). If the Column Index nevertheless marked
a page as all-null, `fillConstantPagesAndDecodeRest` dereferenced the missing
null map and crashed.

An all-null page is now recorded only when `need_null_map` holds, so the
inconsistent file goes through the normal decode path and fails with
`ATTEMPT_TO_READ_AFTER_EOF` instead. The fill also throws `LOGICAL_ERROR`
if the null map is unexpectedly missing.

Add test 05819 with a hand-crafted inconsistent file and exclude the fixture
from `00900_long_parquet_load_2`, which loads every file in `data_parquet`.

Co-authored-by: Cursor <cursoragent@cursor.com>
…s malformed

With `input_format_parquet_use_column_index_for_constant_columns` the Column Index
of every eligible column is read even when the column has no predicate, and
regardless of `input_format_parquet_use_offset_index` and
`input_format_parquet_page_filter_push_down`. A malformed Column Index then failed
the query with a hint to use `input_format_parquet_page_filter_push_down=0`, which
does not turn off that read.

Pick the hint from the reason the Column Index was read: the constant-column
setting, the page filter push-down setting, or both. Document in the setting
description and in the design doc that the force-load is an explicit opt-in that
overrides the two other settings.

Add test 05820 with a hand-crafted file whose Column Index has `min_value > max_value`,
and exclude the fixture from `00900_long_parquet_load_2`.

Co-authored-by: Cursor <cursoragent@cursor.com>
… detection

`detectConstantSubchunk`, `willFillConstantPages` and `fillConstantPagesAndDecodeRest`
started from the first page of the column chunk for every row subgroup and
skipped pages one by one until reaching the subgroup. With many subgroups and
many pages this made the work per column quadratic in the number of subgroups
times pages.

Page locations are strictly increasing by `first_row_index` (validated in
`decodeOffsetIndex`), so find the first overlapping page with a binary search
(`firstPageOverlapping`) and stop the scan at the first page that starts after
the subgroup. Results are unchanged; covered by the existing tier-2 and fill tests,
including 05821.

Co-authored-by: Cursor <cursoragent@cursor.com>
ianton-ru and others added 5 commits December 1, 2026 09:40
Cover the paths the constant-column work added without tests:
- constant and all-null subgroups taken from the Column Index
  (`input_format_parquet_use_column_index_for_constant_columns`), with results
  compared to the optimization off, including `GROUP BY` and a predicate on a
  column whose Column Index is loaded;
- the `ParquetConstantColumnSubchunks` profile event: it fires with the
  force-load setting, and does not without it, with the optimization off, or for
  a `Float64` column;
- the mixed fill (`input_format_parquet_fill_constant_pages`): same result and
  fewer data pages read.

Co-authored-by: Cursor <cursoragent@cursor.com>
…lumn work

- `ColumnChunk::PageConstInfo`: `is_const` is set for `BYTE_ARRAY` and
  `FIXED_LEN_BYTE_ARRAY` too (a per-page `min_value == max_value` proves one exact
  value), but never for floating point.
- Constant values are in the output domain, which is also the decoded domain,
  because columns that need a cast are not eligible.
- `determinePagesToPrefetch` already does not claim the pages of a constant
  subgroup, so drop the "separate follow-up" note.
- Design doc: add the frontmatter and header anchors required for `docs/`, fix
  the tier text that said strings are only safe at tier 1, and replace the "needs
  a build + correctness tests" note for the mixed fill.

Co-authored-by: Cursor <cursoragent@cursor.com>
Follow-up to the binary search for the first overlapping page: `detectConstantSubchunk`
and `willFillConstantPages` still looped over all later pages and skipped each
one. Page locations are strictly increasing, so `break` at the first page that
starts at or after the end of the subgroup.

Co-authored-by: Cursor <cursoragent@cursor.com>
…eds checksums off

`input_format_parquet_use_column_index_for_constant_columns` has no effect while
`input_format_parquet_verify_checksums` is enabled (its default), because columns are
not eligible for the constant-column optimization then. Say so in the setting description.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Drop the binary search for the first overlapping page; the early `break` in
  `detectConstantSubchunk` and `willFillConstantPages` is enough, since a subgroup
  count times a page count of integer compares is negligible next to decoding.
- Use one error hint for a malformed Column Index that names both
  `input_format_parquet_page_filter_push_down` and
  `input_format_parquet_use_column_index_for_constant_columns`, instead of choosing
  between them; trim test 05820 and the design doc accordingly.
- Make `minMaxEqualityProvesSingleValue` a file-local function instead of a
  public member of `Reader`, and shorten the comment on the all-null page check.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ianton-ru

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T11:50:52.656999Z b4b8276 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d59d6877ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +3883 to +3885
if (output_info.idx_in_output_block.has_value()
&& *output_info.idx_in_output_block < row_subgroup.block_missing_values.getNumColumns())
row_subgroup.block_missing_values.setBits(*output_info.idx_in_output_block, num_rows);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Do not mark explicit nullable NULLs as omitted

When checksum verification is disabled and an all-null Parquet chunk is read into a nullable output, this marks every explicit NULL as a missing field. With input_format_defaults_for_omitted_fields enabled, AddingDefaultsTransform can consequently replace those NULLs with the destination column's DEFAULT expression during an insert; the normal nullable decode path consumes the null map into ColumnNullable and does not set these bits. Only the non-nullable null_as_default case should be reported as missing.

Useful? React with 👍 / 👎.

ianton-ru and others added 4 commits December 1, 2026 11:30
…s_default

An all-null constant chunk is returned as ColumnConst, and its rows are marked in
block_missing_values so AddingDefaultsTransform replaces them with the column DEFAULT.
AddingDefaultsTransform only handles full columns: for a numeric column it threw
LOGICAL_ERROR "Unexpected type on mixNumberColumns", and for a String column it silently
kept the empty value instead of the DEFAULT. Expand the constant before returning it.

Test: 05822_parquet_constant_null_as_default
Co-authored-by: Cursor <cursoragent@cursor.com>
…t_null_as_default

6005f3c expanded an all-null constant column and recorded its rows in
block_missing_values for every output type. For a Nullable output the normal
decode path never records NULL rows there, so AddingDefaultsTransform replaced
the NULLs with the column DEFAULT. With input_format_null_as_default and
checksums verification disabled, a Nullable column with an all-null constant
chunk was inserted with DEFAULT values instead of NULL.

Record the rows and expand the constant only for non-nullable outputs, where
the NULLs are substituted by the default, and add a regression test.

Closes: #2976
Co-authored-by: Cursor <cursoragent@cursor.com>
… estimate

A constant column chunk or subchunk is delivered as a single-value `ColumnConst` and never
decoded, but `estimateColumnMemoryBytesPerRow` still estimated it as a full column. That made
`input_format_parquet_prefer_block_bytes` produce smaller blocks than needed and reserved decode
memory for columns that allocate nothing.

The estimate is now zero for a constant chunk, and the `ColumnData` reservation is skipped for a
constant subchunk. An all-null constant read into a non-nullable column is still estimated,
because `formOutputColumn` expands it to a full column of defaults.

Related: #2976
Co-authored-by: Cursor <cursoragent@cursor.com>
…ected

`ParquetConstantColumnChunks` was incremented when a chunk was detected as constant, which happens
for every row group that survives the footer pruning, including row groups that this reader does not
process, row groups pruned later by the bloom or dictionary filter, and row groups where a filter
removes every row. `ParquetConstantColumnSubchunks` was counted for subgroups that decode nothing.

Both events are now incremented in `decodePrimitiveColumn`, where a subgroup is actually served from
the constant. A whole-chunk constant is counted once, by the first subgroup that uses it.

Related: #2976
Co-authored-by: Cursor <cursoragent@cursor.com>
@ianton-ru

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4b8276aa5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/// null_count == 0). A Column Index that contradicts the footer is left to the normal decode path,
/// which reports the inconsistency.
if (record_page_const)
column.page_const_info[page_idx].all_null = nullable && column.need_null_map && always_null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject contradictory all-null page metadata

When checksum verification is disabled and the Column Index is loaded, a nullable page with null_pages[page_idx] = true but a contradictory null_counts[page_idx] (for example, zero) is still marked all_null. Constant-subchunk detection or mixed-page filling then skips the data page and emits NULLs, so a malformed external file whose page actually contains values produces silently incorrect results instead of the documented malformed-index error. Validate null_counts against the page row count before trusting null_pages, and reject the index or decode the page normally when they disagree.

AGENTS.md reference: AGENTS.md:L157-L157

Useful? React with 👍 / 👎.

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

antalya antalya-26.8 performance Antalya Roadmap: Performance port-antalya PRs to be ported to all new Antalya releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants