Skip to content

fix(cpp): preserve table time statistics in filtered metadata - #989

Merged
ColinLeeo merged 4 commits into
apache:developfrom
ColinLeeo:colin/fix-table-footer-statistics
Oct 6, 2026
Merged

ColinLeeo merged 4 commits into
apache:developfrom
ColinLeeo:colin/fix-table-footer-statistics

Conversation

@ColinLeeo

@ColinLeeo ColinLeeo commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Filtered table metadata discarded the shared time index, so tsfile-cli stats could report an empty null_count for a normally written table even though its footer contained the entity row count. Reuse the existing offset-based metadata reader to retain the aligned time index. The existing statistics calculation can then subtract each field's non-null count from the footer's row count.

Regression coverage verifies that filtered metadata retains the shared time statistic and checks complete CSV output for normally written sparse fields, including both zero and nonzero null counts. CSV, NDJSON, and table golden outputs are updated accordingly. The production change is confined to the metadata reader; CLI scan conditions remain at their baseline behavior.

Validation:

  • Built TsFile_Test and tsfile_cli in an isolated Release build with LZ4 enabled and the other optional codecs and ANTLR4 disabled.
  • All 116 relevant reader, CLI, statistics, and metadata/empty-file golden tests passed; one existing test remains disabled.
  • Targeted C++ Spotless and whitespace checks passed.

ColinLeeo added a commit to ColinLeeo/tsfile that referenced this pull request Oct 5, 2026
Revert the statistics changes from dbccee3, including their later formatting, now maintained in apache#989. Keep PR apache#970 focused on table read error propagation and preserve its subsequent error handling changes.

Validation: Release build, 136 reader/CLI/statistics/golden/read-failure tests, targeted Spotless, and whitespace checks passed.
@ColinLeeo
ColinLeeo requested a balanced review from Copilot October 5, 2026 11:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unreliable zero-count timelines can still bypass scanning and produce negative null counts, and the fallback branch lacks effective regression coverage.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Preserves aligned time statistics in filtered C++ metadata so CLI table statistics can report numeric null counts.

Changes:

  • Reuses offset-based metadata loading to retain shared time indexes.
  • Adds scan fallback logic for missing timelines.
  • Updates regression tests and golden outputs.
File Description
cpp/​src/​file/​tsfile_io_reader.cc Preserves aligned time metadata.
cpp/​tools/​commands/​cmd_stats.cc Expands scan fallback conditions.
cpp/​test/​reader/​tsfile_reader_test.cc Verifies filtered time indexes.
cpp/​test/​tools/​command_e2e_test.cc Adds sparse-field coverage.
cpp/​test/​tools/​golden/​table_stats_csv.txt Updates CSV null counts.
cpp/​test/​tools/​golden/​table_stats_ndjson.txt Updates NDJSON null counts.
cpp/​test/​tools/​golden/​table_stats_table.txt Updates table null counts.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cpp/tools/commands/cmd_stats.cc Outdated
Comment thread cpp/test/tools/command_e2e_test.cc Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused reader change is consistent with existing behavior and has appropriate regression coverage.

Review effort: Balanced
Findings: None

Resolved since last review (2)

@ColinLeeo
ColinLeeo merged commit b9a9cfa into apache:develop Oct 6, 2026
39 checks passed
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.

2 participants