What happens?
ASOF JOIN combined with a LIMIT clause causes the query to hang forever (never returns) when the input CTEs/tables contain 64 or more rows. With fewer than 64 rows it produces correct results. Removing LIMIT works correctly for any number of rows.
To Reproduce
import duckdb
con = duckdb.connect()
sql = """
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
"""
df = con.execute(sql).df() # <-- hangs here forever
print(df)
OS:
OSX, Windows
DuckDB Package Version:
1.5
Python Version:
3.10-3.14
Full Name:
Aliaksandr Zhura
Affiliation:
Infio
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
Did you include all relevant data sets for reproducing the issue?
No - Other reason (please specify in the issue body)
Did you include all code required to reproduce the issue?
Did you include all relevant configuration to reproduce the issue?
What happens?
ASOF JOIN combined with a LIMIT clause causes the query to hang forever (never returns) when the input CTEs/tables contain 64 or more rows. With fewer than 64 rows it produces correct results. Removing LIMIT works correctly for any number of rows.
To Reproduce
OS:
OSX, Windows
DuckDB Package Version:
1.5
Python Version:
3.10-3.14
Full Name:
Aliaksandr Zhura
Affiliation:
Infio
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have tested with a stable release
Did you include all relevant data sets for reproducing the issue?
No - Other reason (please specify in the issue body)
Did you include all code required to reproduce the issue?
Did you include all relevant configuration to reproduce the issue?