File: test_asof_limit.test

package info (click to toggle)
duckdb 1.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 299,196 kB
  • sloc: cpp: 865,414; ansic: 57,292; python: 18,871; sql: 12,663; lisp: 11,751; yacc: 7,412; lex: 1,682; sh: 747; makefile: 564
file content (33 lines) | stat: -rw-r--r-- 847 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# name: test/sql/join/asof/test_asof_limit.test
# description: Test As-Of join usage with LIMIT clauses
# group: [asof]

# Don't die when limit stops calling us
statement ok
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;