custom indicators fixed

This commit is contained in:
2026-04-09 17:00:43 -04:00
parent a70dcd954f
commit fd431516cc
17 changed files with 778 additions and 440 deletions

View File

@@ -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
`;