Skip to content

refactor(query): unify window/cte spill to async_buffer path #20001

Merged
dqhl76 merged 1 commit into
databendlabs:mainfrom
dqhl76:clean-aggregate
Jun 14, 2026
Merged

refactor(query): unify window/cte spill to async_buffer path #20001
dqhl76 merged 1 commit into
databendlabs:mainfrom
dqhl76:clean-aggregate

Conversation

@dqhl76

@dqhl76 dqhl76 commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

refactor(query): unify window/cte spill to async_buffer path

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions Bot added the pr-refactor this PR changes the code base without new features or bugfix label Jun 12, 2026
@dqhl76 dqhl76 force-pushed the clean-aggregate branch 2 times, most recently from 74d562f to d07c366 Compare June 12, 2026 06:06
@dqhl76 dqhl76 marked this pull request as ready for review June 12, 2026 07:09

@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: d07c3663f3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@dqhl76 dqhl76 force-pushed the clean-aggregate branch 2 times, most recently from 6ed3478 to 114f643 Compare June 12, 2026 08:37
Migrate WindowPartitionBufferV2 and MaterializedCTE from the
BackpressureSpiller -> WriterCreator -> SpillWriter -> AnyFileWriter
chain to the SpillsBufferPool -> SpillsDataWriter/SpillsDataReader
path used by aggregate and join operators.

Key changes:
- Rewrite window_partition_buffer_v2 to use SpillsDataWriter directly
- Rewrite materialized_cte to use SpillsBufferPool.writer()
- Remove BackpressureSpiller, WriterCreator, SpillWriter, SpillReader
- Remove row_group_encoder.rs (FileWriter, LocalWriter, AnyFileWriter,
  RowGroupEncoder, Properties, RangeFetchPlan, FileReader)
- Remove V1 WindowPartitionBuffer (async Spiller path)
- Drop local DMA support for window/cte spill
- Add SpillsDataWriter::flush_row_group() for explicit row group control

Reduce from 5-state machine (Collect/Spill/Process/Restore/Finish) to
3-state (Collect/Output/Finish). Since spill and restore are now both
synchronous, the indirection through separate Spill/Restore steps with
async fallback is unnecessary.

- Collect: pull data, buffer, spill inline when memory pressure is high
- Output: restore next partition, process (sort), push downstream
- Remove next_step(), collect(), output() helper methods
- Remove is_collect_finished, restored_data_blocks fields
@dqhl76 dqhl76 force-pushed the clean-aggregate branch from 114f643 to 5f09d6d Compare June 12, 2026 08:39
@dqhl76 dqhl76 requested review from forsaken628 and zhang2014 June 12, 2026 09:43
@dqhl76 dqhl76 added this pull request to the merge queue Jun 14, 2026
Merged via the queue into databendlabs:main with commit 6a9372d Jun 14, 2026
91 checks passed
@dqhl76 dqhl76 deleted the clean-aggregate branch June 14, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-refactor this PR changes the code base without new features or bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants