You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(spec,driver-sql,formula): addDays whole-day offset on a field reference, compiled on SQL and evaluated in memory (#15102)
* feat(spec,formula): addDays whole-day offset on a field reference (wip)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vx3536MUFc8XYVLNoKhs3
* feat(driver-sql): compile the addDays offset on the cross-field arm, corpus rows on both paths (wip)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vx3536MUFc8XYVLNoKhs3
* test(service-analytics),docs: offset routing + dataset pin, query-syntax section, changesets, regenerated spec artifacts (wip)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vx3536MUFc8XYVLNoKhs3
* feat(spec,driver-sql,formula): addDays whole-day offset on a field reference, compiled on SQL and evaluated in memory
FieldReferenceSchema gains addDays — an integer literal of any sign or a nested
{ $field } reference to a numeric column — so a dataset measure can express
completed_at <= due_date + grace_days. driver-sql compiles the offset on the
cross-field arm per dialect with the ruled NULL semantics written into the
predicate; matchesFilter evaluates it identically; the shared conformance corpus
carries the literal, column, negative, NULL-offset, NULL-base and $not rows on
both paths; the analytics detector keeps routing the reference to the engine
path and a dataset-level pin drives the on-time count on both.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019vx3536MUFc8XYVLNoKhs3
---------
Co-authored-by: Claude <noreply@anthropic.com>
`addDays` adds a **whole-day offset** to the referenced column before the comparison:
497
+
an integer literal of any sign, or a nested `{ $field }` reference to a numeric column
498
+
holding the number of days. Whole days are the only unit. The NULL semantics are
499
+
stated rather than inherited from SQL three-valued logic:
500
+
501
+
| Case | Reads as |
502
+
|:-----|:---------|
503
+
| The offset column is NULL | zero days — `due_date + NULL` is `due_date`|
504
+
| The referenced column is NULL | the comparison is **false**, for every operator (`$ne` included) — no deadline is never "on time", so `$not` re-admits the row |
505
+
| The target column is NULL | its ordinary reading — fails the orderings and `$eq`, satisfies `$ne` when the offset deadline exists |
506
+
507
+
On SQL push-down the offset compiles only between two temporal columns of the same
508
+
class (`date` with `date`, `datetime` with `datetime`) against a numeric offset column,
509
+
on every dialect the `$field` compiler covers (SQLite, PostgreSQL, MySQL); the
510
+
memory evaluator matches, and a fractional offset *value* is truncated toward zero on
511
+
both. The same-table rule applies to the offset column too: `addDays: {$field:
512
+
'duty.grace_days'}` (a relation path) is resolved by the memory evaluator and refused
513
+
by SQL push-down with `INVALID_FILTER`, exactly as a dotted `$field` is.
514
+
460
515
### Date, Datetime, and Time Filters
461
516
462
517
Before a comparison is built, the driver puts the comparand into the **same canonical
Copy file name to clipboardExpand all lines: content/docs/references/data/filter.mdx
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,15 @@ const result = EqualityOperatorSchema.parse(data);
60
60
| Property | Type | Required | Description |
61
61
| :--- | :--- | :--- | :--- |
62
62
|**$field**|`string`| ✅ | Field Reference/Column Name |
63
+
|**addDays**|`integer \| { $field: string }`| optional | Whole-day offset added to the referenced column before comparing: an integer literal of any sign (negative subtracts; whole days only), or a `{ $field }` reference to a numeric column. A NULL offset column contributes zero days; a NULL referenced column makes the comparison false rather than NULL, so it stays false under $not. Compiles on SQL push-down between two temporal columns of the same class (date/date, datetime/datetime) and evaluates identically in memory. |
64
+
65
+
### Nested Shape: `FieldReference.addDays`
66
+
67
+
A `{ $field }` reference to the numeric column holding the day offset
68
+
69
+
| Property | Type | Required | Description |
70
+
| :--- | :--- | :--- | :--- |
71
+
|**$field**|`string`| ✅ | Numeric column whose value is the number of days to add |
0 commit comments