Skip to content

query: fix empty Contacts view in TUI Texts mode (DuckDB OOM)#361

Open
bjabes wants to merge 1 commit into
kenn-io:mainfrom
bjabes:bjabes/fix-tui-contacts-query
Open

query: fix empty Contacts view in TUI Texts mode (DuckDB OOM)#361
bjabes wants to merge 1 commit into
kenn-io:mainfrom
bjabes:bjabes/fix-tui-contacts-query

Conversation

@bjabes
Copy link
Copy Markdown
Contributor

@bjabes bjabes commented May 31, 2026

The TUI's Texts-mode Contacts and Contact Names aggregate views came up empty because the DuckDB engine resolved each message's sender with a correlated scalar subquery inside the JOIN ON clause, which DuckDB couldn't push the message-type filter through — so it scanned the entire email-dominated messages dataset and exhausted memory. This rewrites the join to resolve the 'from' participant via an uncorrelated derived table while preserving the COALESCE(sender_id, from-recipient) semantics; against a ~1M-row text cache it drops from OOM to ~150ms. SQLite mode was already unaffected. Also adds the first DuckDB TextAggregate test coverage (Contacts + Contact Names), extending the fixture builder with MessageType/SenderID so text messages can be modeled.

The DuckDB text Contacts/Contact-Names aggregates resolved the sending
participant with a correlated scalar subquery embedded in the JOIN ON
clause. DuckDB cannot push the message_type filter through a correlated
join, so it evaluated the subquery across the entire email-dominated
messages dataset and exhausted temp memory — surfacing as an empty/error
Contacts view in the TUI (SQLite mode was unaffected).

Resolve the 'from' participant via an uncorrelated derived table joined
on message_id instead, preserving COALESCE(sender_id, from-recipient)
semantics. Against a real ~1M-row text cache this drops from OOM to
~150ms.

Add the first DuckDB TextAggregate coverage (Contacts + Contact-Names),
extending the test fixture builder with MessageType/SenderID so text
messages can be modeled.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented May 31, 2026

roborev: Combined Review (e5a922b)

No Medium, High, or Critical findings; both reviews found the change clean.


Synthesized from 2 reviews (agents: codex | types: default, security)

@roborev-ci
Copy link
Copy Markdown

roborev-ci Bot commented Jun 1, 2026

roborev: Pass

No issues found.


Review type: | Agent: codex | Job: 19264

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