custom indicators fixed
This commit is contained in:
@@ -405,22 +405,25 @@ export class DuckDBClient {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Query the Iceberg table with filters
|
||||
// Query the Iceberg table with filters, deduplicating by ingested_at so that
|
||||
// duplicate parquet files (e.g. from repeated Flink job runs on the same key
|
||||
// range) never produce more than one row per (ticker, period_seconds, timestamp).
|
||||
const sql = `
|
||||
SELECT
|
||||
timestamp,
|
||||
ticker,
|
||||
period_seconds,
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close,
|
||||
volume
|
||||
FROM iceberg_scan('${tablePath}')
|
||||
WHERE ticker = ?
|
||||
AND period_seconds = ?
|
||||
AND timestamp >= ?
|
||||
AND timestamp < ?
|
||||
SELECT timestamp, ticker, period_seconds, open, high, low, close, volume
|
||||
FROM (
|
||||
SELECT
|
||||
timestamp, ticker, period_seconds, open, high, low, close, volume, ingested_at,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY timestamp
|
||||
ORDER BY ingested_at DESC
|
||||
) AS rn
|
||||
FROM iceberg_scan('${tablePath}')
|
||||
WHERE ticker = ?
|
||||
AND period_seconds = ?
|
||||
AND timestamp >= ?
|
||||
AND timestamp < ?
|
||||
)
|
||||
WHERE rn = 1
|
||||
ORDER BY timestamp ASC
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user