Issue #21244: AsOf Unordered LIMIT by hawkfish · Pull Request #21250 · duckdb/duckdb · GitHub
Skip to content

Issue #21244: AsOf Unordered LIMIT - #21250

Merged
Mytherin merged 3 commits into
duckdb:v1.5-variegatafrom
hawkfish:asof-limit
Mar 12, 2026
Merged

Mytherin merged 3 commits into
duckdb:v1.5-variegatafrom
hawkfish:asof-limit

Conversation

@hawkfish

@hawkfish hawkfish commented Mar 9, 2026

Copy link
Copy Markdown
Member
  • Add missing break when a thread has no more tasks and unblocks.

* Add missing break when a thread has no more tasks and unblocks.
@hawkfish
hawkfish requested a review from Mytherin March 9, 2026 21:29
@hawkfish

hawkfish commented Mar 9, 2026

Copy link
Copy Markdown
Member Author

@hawkfish

hawkfish commented Mar 9, 2026

Copy link
Copy Markdown
Member Author

Serialisation error also appears unrelated.

@Mytherin

Copy link
Copy Markdown
Member

Thanks! Looks good - the verification failure looks to be related though:

1. test/sql/join/asof/test_asof_join.test:92
================================================================================
Query unexpectedly failed! (test/sql/join/asof/test_asof_join.test:92)!
================================================================================
WITH trades AS (
    SELECT
        'AAPL' AS symbol,
        TIMESTAMP '2024-01-01 10:00:00' + idx * INTERVAL 10 SECONDS AS trade_time,
        100 AS quantity
    FROM range(64) AS trade_rows(idx)   -- hangs; change to 63 to succeed
),
quotes AS (
    SELECT
        'AAPL' AS symbol,
        TIMESTAMP '2024-01-01 09:59:50' + idx * INTERVAL 10 SECONDS AS quote_time,
        150.0 AS price
    FROM range(64) AS quote_rows(idx)
)
SELECT
    t.symbol,
    t.trade_time,
    t.quantity,
    q.quote_time,
    q.price,
    t.quantity * q.price AS notional
FROM trades AS t
ASOF LEFT JOIN quotes AS q
    ON t.symbol = q.symbol
   AND t.trade_time >= q.quote_time
LIMIT 5;
================================================================================
Invalid Error: Unoptimized statement differs from original result!
Original Result:
symbol	trade_time	quantity	quote_time	price	notional	
VARCHAR	TIMESTAMP	INTEGER	TIMESTAMP	DECIMAL(4,1)	DECIMAL(14,1)	
[ Rows: 5]
AAPL	2024-01-01 10:00:00	100	2024-01-01 10:00:00	150.0	15000.0
AAPL	2024-01-01 10:00:10	100	2024-01-01 10:00:10	150.0	15000.0
AAPL	2024-01-01 10:00:20	100	2024-01-01 10:00:20	150.0	15000.0
AAPL	2024-01-01 10:00:30	100	2024-01-01 10:00:30	150.0	15000.0
AAPL	2024-01-01 10:00:40	100	2024-01-01 10:00:40	150.0	15000.0

Unoptimized:
symbol	trade_time	quantity	quote_time	price	notional	
VARCHAR	TIMESTAMP	INTEGER	TIMESTAMP	DECIMAL(4,1)	DECIMAL(14,1)	
[ Rows: 5]
AAPL	2024-01-01 10:00:10	100	2024-01-01 10:00:10	150.0	15000.0
AAPL	2024-01-01 10:01:30	100	2024-01-01 10:01:30	150.0	15000.0
AAPL	2024-01-01 10:02:50	100	2024-01-01 10:02:50	150.0	15000.0
AAPL	2024-01-01 10:04:30	100	2024-01-01 10:04:30	150.0	15000.0
AAPL	2024-01-01 10:04:40	100	2024-01-01 10:04:40	150.0	15000.0

Might just be due to a missing ORDER BY in the query

@duckdb-draftbot
duckdb-draftbot marked this pull request as draft March 10, 2026 20:06
@hawkfish
hawkfish marked this pull request as ready for review March 10, 2026 20:50
@Mytherin
Mytherin merged commit a73b64c into duckdb:v1.5-variegata Mar 12, 2026
109 checks passed
@Mytherin

Copy link
Copy Markdown
Member

@hawkfish
hawkfish deleted the asof-limit branch March 12, 2026 15:47
github-actions Bot pushed a commit to duckdb/duckdb-r that referenced this pull request Mar 18, 2026
Date: 2026-03-12 10:15:22 +0100

Issue duckdb/duckdb#21244: AsOf Unordered LIMIT (duckdb/duckdb#21250)
Windows shell: fix UTF-8 to UTF-16 conversion (duckdb/duckdb#21319)
Fix Row Group Reorderer Bug (duckdb/duckdb#21282)
github-actions Bot added a commit to duckdb/duckdb-r that referenced this pull request Mar 18, 2026
Date: 2026-03-12 10:15:22 +0100

Issue duckdb/duckdb#21244: AsOf Unordered LIMIT (duckdb/duckdb#21250)
Windows shell: fix UTF-8 to UTF-16 conversion (duckdb/duckdb#21319)
Fix Row Group Reorderer Bug (duckdb/duckdb#21282)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Mar 22, 2026
Date: 2026-03-12 10:15:22 +0100

Issue duckdb/duckdb#21244: AsOf Unordered LIMIT (duckdb/duckdb#21250)
Windows shell: fix UTF-8 to UTF-16 conversion (duckdb/duckdb#21319)
Fix Row Group Reorderer Bug (duckdb/duckdb#21282)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
krlmlr added a commit to krlmlr/duckdb-r-old that referenced this pull request Mar 22, 2026
Date: 2026-03-12 10:15:22 +0100

Issue duckdb/duckdb#21244: AsOf Unordered LIMIT (duckdb/duckdb#21250)
Windows shell: fix UTF-8 to UTF-16 conversion (duckdb/duckdb#21319)
Fix Row Group Reorderer Bug (duckdb/duckdb#21282)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
krlmlr added a commit to krlmlr/duckdb-r-old that referenced this pull request Mar 22, 2026
Date: 2026-03-12 10:15:22 +0100

Issue duckdb/duckdb#21244: AsOf Unordered LIMIT (duckdb/duckdb#21250)
Windows shell: fix UTF-8 to UTF-16 conversion (duckdb/duckdb#21319)
Fix Row Group Reorderer Bug (duckdb/duckdb#21282)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
kaka11chen pushed a commit to AstroVela/vane that referenced this pull request Aug 14, 2026
* Add missing break when a thread has no more tasks and unblocks.

Upstream-Commit: duckdb/duckdb@a73b64c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants