T-212: M2.3t — Add --qm-financials-old merge and Option B --from-mongo streaming for M2 collections in curate-etl
This commit is contained in:
parent
60ab228207
commit
f082aac436
12 changed files with 518 additions and 131 deletions
|
|
@ -2009,11 +2009,15 @@ function planCrossSectionInternal(
|
|||
const lookbackStartDate = formatUtcDate(lookbackStartMs);
|
||||
const endDate = formatUtcDate(fenced.toMs);
|
||||
const fromIso = formatUtcIsoWithMicros(fenced.fromMs, 0);
|
||||
const toIso = formatUtcIsoWithMicros(fenced.toMs, resolveToSubMsMicros(q.date, fenced));
|
||||
const asOfIso = formatUtcIsoWithMicros(
|
||||
fenced.asOfMs,
|
||||
resolveAsOfSubMsMicros(rawAsOf, q.date, fenced)
|
||||
);
|
||||
const toSubMsMicros = resolveToSubMsMicros(q.date, fenced);
|
||||
const asOfSubMsMicros = resolveAsOfSubMsMicros(rawAsOf, q.date, fenced);
|
||||
const toIso = formatUtcIsoWithMicros(fenced.toMs, toSubMsMicros);
|
||||
const asOfIso = formatUtcIsoWithMicros(fenced.asOfMs, asOfSubMsMicros);
|
||||
const universeKnownAtIso =
|
||||
fenced.asOfMs < fenced.toMs ||
|
||||
(fenced.asOfMs === fenced.toMs && asOfSubMsMicros < toSubMsMicros)
|
||||
? asOfIso
|
||||
: toIso;
|
||||
const featureYear = new Date(fenced.fromMs).getUTCFullYear();
|
||||
|
||||
const barsPath = joinCuratedPath(curatedRoot, 'bars_1d/year=*/part.parquet');
|
||||
|
|
@ -2025,7 +2029,13 @@ function planCrossSectionInternal(
|
|||
const ctes: string[] = [
|
||||
`u AS (SELECT DISTINCT b.listing_id FROM read_parquet('${barsPath}', hive_partitioning = true) AS b WHERE ${currencyPredicate} AND b.session_date >= ? AND b.session_date <= ? AND b.ts <= ? AND b.known_at <= ?)`,
|
||||
];
|
||||
const params: DuckDbParam[] = [...currencies, lookbackStartDate, endDate, toIso, asOfIso];
|
||||
const params: DuckDbParam[] = [
|
||||
...currencies,
|
||||
lookbackStartDate,
|
||||
endDate,
|
||||
toIso,
|
||||
universeKnownAtIso,
|
||||
];
|
||||
|
||||
const selectCols: string[] = ['u.listing_id'];
|
||||
const joins: string[] = [];
|
||||
|
|
|
|||
|
|
@ -3464,6 +3464,50 @@ describe('planCrossSectionQuery and store.crossSection', () => {
|
|||
DEFAULT_CTX
|
||||
)
|
||||
).toThrow(VaultHoldoutFenceError);
|
||||
|
||||
// Later explicit asOf caps universe membership at end-of-date while retaining asOf for features.
|
||||
const laterAsOf = planCrossSectionQuery(
|
||||
{
|
||||
features: ['ret_1d@v1'],
|
||||
date: '2025-06-07',
|
||||
universe: 'US_EQ',
|
||||
asOf: '2025-06-10',
|
||||
},
|
||||
DEFAULT_CTX
|
||||
);
|
||||
expect(laterAsOf.params).toEqual([
|
||||
'USD',
|
||||
'2025-05-31',
|
||||
'2025-06-07',
|
||||
'2025-06-07T23:59:59.999999Z',
|
||||
'2025-06-07T23:59:59.999999Z',
|
||||
2025,
|
||||
'2025-06-07T00:00:00.000Z',
|
||||
'2025-06-07T23:59:59.999999Z',
|
||||
'2025-06-10T23:59:59.999999Z',
|
||||
]);
|
||||
|
||||
// Earlier explicit intraday asOf applies to both universe membership and features.
|
||||
const earlierAsOf = planCrossSectionQuery(
|
||||
{
|
||||
features: ['ret_1d@v1'],
|
||||
date: '2025-06-07',
|
||||
universe: 'US_EQ',
|
||||
asOf: '2025-06-07T21:00:00Z',
|
||||
},
|
||||
DEFAULT_CTX
|
||||
);
|
||||
expect(earlierAsOf.params).toEqual([
|
||||
'USD',
|
||||
'2025-05-31',
|
||||
'2025-06-07',
|
||||
'2025-06-07T23:59:59.999999Z',
|
||||
'2025-06-07T21:00:00.000Z',
|
||||
2025,
|
||||
'2025-06-07T00:00:00.000Z',
|
||||
'2025-06-07T23:59:59.999999Z',
|
||||
'2025-06-07T21:00:00.000Z',
|
||||
]);
|
||||
});
|
||||
|
||||
it('maps nullable feature values via store.crossSection and rejects invalid/post-cutoff requests with zero extra calls', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue