Conversation
The quickstart defines a flip as buying an item and reselling it at a
higher price "within an 8-day period", but the query never enforced that
bound.
datediff(unit, start, end) returns end - start, so
datediff('days', w2.bid_time, w1.bid_time) evaluates to
purchase_time - sale_time. For any genuine flip the purchase precedes
the sale, making the value negative and therefore always < 8. The window
was inert: a resale years after the purchase still qualified, and the
timeframe_days column reported a negative number on every real flip.
Swap the arguments so the value is sale - purchase, and add an explicit
ordering predicate, since "< 8" alone still admits pairs whose sale
precedes the purchase.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W1yEF7rh559n9vxcrSpwWs
The quickstart already explains that the self-join grows quadratically in winning_bids and adds indexes to make each query cheaper. It did not say that an index or materialized view over flip_activities retains that state continuously, or that the 8-day bound is what keeps the growth linear. Add a short paragraph after the index step saying so and pointing at temporal filters. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W1yEF7rh559n9vxcrSpwWs
bosconi
marked this pull request as ready for review
September 16, 2026 00:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The quickstart defines a flip as buying an item and reselling it at a higher price "within an 8-day period", but the query never enforced that bound.
datediff(unit, start, end)returnsend - start, sodatediff('days', w2.bid_time, w1.bid_time)evaluates topurchase_time - sale_time.w1is the purchase leg andw2the sale leg, so for any genuine flip this is negative and therefore always< 8.Two consequences:
timeframe_daysreports a negative number on every genuine flip.This swaps the arguments so the value is
sale - purchase, and adds an explicit ordering predicate, since< 8alone still admits pairs whose sale precedes the purchase.Found while investigating memory growth in a demo derived from this quickstart. Worth noting the view is quadratic either way — the fixed window bounds it only once the data spans well beyond 8 days — so this is a correctness fix, not a performance one.
A second commit adds a short note after the index step: the view's output grows with
winning_bids, the 8-day bound is what keeps that growth linear rather than quadratic, and an index or materialized view overflip_activitiesretains that state continuously, so keep the bound or add a temporal filter onwinning_bids.Manual testing
Run in the Materialize Cloud Console SQL shell. Constant queries, no tables involved.
1. Sign convention of
datediff:2. The quickstart's expression applied to a genuine flip (bought Jan 1, sold Jan 5):
3. The 8-day bound does nothing (same flip, sold five years later):
A resale 1,826 days after the purchase passes a filter the prose describes as "within an 8-day period". With the arguments swapped, query 2 reports
4and query 3 reports1826, which the< 8bound then correctly rejects.🤖 Generated with Claude Code
https://claude.ai/code/session_01W1yEF7rh559n9vxcrSpwWs