Repository navigation
Fix DuckDB FIFO allocations without a matching receipt layer - #14
Merged
sfc-gh-dhuang merged 1 commit intoNov 12, 2026
Merged
Conversation
lluisinthedesert
marked this pull request as ready for review
October 21, 2026 04:34
sfc-gh-dhuang
approved these changes
Nov 11, 2026
sfc-gh-dhuang
left a comment
Collaborator
There was a problem hiding this comment.
confirmed DuckDB 1.2.2 returns 4 for GREATEST(0, LEAST(NULL,7) - GREATEST(NULL,3)) where Snowflake returns 0. After this PR the DuckDB expected values equal the Snowflake ones (19,511 fulfilled).
One thing flagged by one of the reviewer agents - since DuckDB fulfillment rate changes from 0.9465 to 0.1093, this needs a new dataset revision and earlier DuckDB results aren't comparable.
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 DuckDB reference for
fifo-inventory-cogsallocates units to picks with no matching receipt layer. Its expected-results file preserves those allocations, so the shipped reference passes while a NULL-safe implementation fails seven expected-value checks.Root cause
The allocation query LEFT JOINs receipt layers, then computes:
When no layer matches, both receipt bounds are NULL. DuckDB ignores those NULL arguments, leaving
consumption_end - consumption_start: the entire pick quantity. Snowflake propagates NULL, which the reference subsequently converts to zero.A minimal expression reproduces the difference:
DuckDB 1.2.2 returns 4; live Snowflake returns 0.
Effect on the pinned dataset
At
a3278ad102829a6084dde086244a0ef665a8011c:The DuckDB and Snowflake verifiers select different expected files. Consequently both shipped references pass their respective suites, despite the DuckDB allocation exceeding all received inventory.
Intended behavior
A pick without a matching receipt layer must receive zero allocation. The sibling
dbt-multicurrency-liforeference already applies this rule: it evaluates the same range-overlap calculation only whenp.purchase_id IS NOT NULL, otherwise returning zero. This FIFO guard follows that existing repository pattern.The checked-in Snowflake expected results also expect 19,511 fulfilled units, matching the corrected DuckDB allocation rather than the shipped DuckDB total of 187,826.
Impact
The shipped DuckDB reference passes all 50 tests despite allocating more units than were received. Correcting the unmatched-receipt allocation while retaining the original verifier produces seven failures. This means the task can penalize correct allocation logic and reward reproducing the reference bug. Phantom consumption also affects fulfillment and ending-inventory metrics, while the separate backend fixtures grade DuckDB and Snowflake against different inventory outcomes. This is a correctness issue for this task, not a claim about the benchmark as a whole.
Change
r.receipt_id IS NULL.No input data, ticket wording, or Snowflake expected values change. The guard, affected expectations, and regression cover this single root cause.
Validation
Executed the reference and pytest verifier in isolated local projects on macOS arm64, Python 3.12, dbt-core 1.10.23, dbt-duckdb 1.10.0, and dbt-snowflake 1.10.0. Container paths were remapped locally. Snowflake runs used separate database clones with the task's required source inputs from the pinned dataset. These are direct dbt/pytest checks, not Harbor agent runs.