Learn

Contents

The value triple: eod, missing data and errors

Every answer in eLucid8 is a triple: its kind, its value and its timestamp. This page gives every rule about the three, each with a small program and its answers, and the conformance cases that test it. Other pages link here for these rules. The examples are read as How to read the examples says: the comment lines under each program give its inputs' rows and its answers.

The triple

Reads as: an answer is data, eod or an error, with the time of the newest data it was computed from.

Means: a value has an answer at every point. Each answer has three parts:

partwhat it is
kinddata, eod or error
valuefor data, a number, a boolean, a text or a collection; for eod, nothing; for an error, its error kind and its origin, the point where it started (its dimensions in the order its value declares them)
timestampthe time, in milliseconds, of the newest data the answer was computed from; 0 when it read no data with a time

Example:

-- file triple.el8
-- Doubled readings, their total, and where readings are missing.
reading = input("reading", t : 5)
doubled = reading * 2
total = sum reading over (t : 5) end
gap = iserror(reading, "missing")
-- table reading = t,value,ts; 0,4,1000; 1,,2000; 3,6,3000; 4,2,4000
-- expect doubled[t = 0] = 8, at time 1000 ms
-- expect doubled[t = 1] = error missing from reading[t = 1]: input reading has no data at this point, at time 2000 ms
-- expect doubled[t = 2] = error missing from reading[t = 2]: input reading has no data at this point
-- expect doubled[t = 5] = eod
-- expect total = 12, at time 4000 ms
-- expect gap[t = 1] = true, at time 2000 ms

Open in playground

Answers:

pointkindvaluetimestampwhy
doubled[t = 0]data81000 msthe row at t = 0
doubled[t = 1]errormissing, from reading[t = 1]2000 msan empty cell in a row with a time
doubled[t = 2]errormissing, from reading[t = 2]0no row, so no time
doubled[t = 5]eod0outside the bound t : 5
totaldata124000 msthe two missing points left out, and counted in a warning
gap[t = 1]datatrue2000 msiserror gives data, with its operand's timestamp

Check:

  1. What kind is it? eod means the point is outside the data. An error means something went wrong inside the data, and says what and where.
  2. If an error, where did it start? Its origin names a value and a point. Why? in the playground, or elucid8 run --why, leads there.
  3. How new is it? An answer about 9:00 with a timestamp after 9:00 read data from its own future. An answer at timestamp 0 read no data with a time, or only data at a clock's tick 0.
  4. What did an aggregate leave out? The warning beside the answer counts the missing points (aggregates left out 2 missing points of input reading).

Rules:

  1. Every point of every value has exactly one answer, of exactly one kind.
  2. An error's error kind is one of missing, late, failed, division, non-finite, empty, assert, type, index, data, raised and version (Errors). An error passed on keeps the error kind and origin of the error where it started.
  3. The timestamp of an answer computed from others is the latest timestamp among what it read, by the rules of Values and timestamps. Data read from an input has its row's time, or its clock's time.
  4. eod, missing data and other errors are different answers, and nothing turns one into another by itself. A program turns one into another only by writing it: default, iseod, iserror, if.
  5. Caches, compiled loops, threads and memory management never change an answer's kind, value or timestamp.

Tested by the conformance cases (Conformance) error-kinds, column-gap-time-zero and data-ends-finite.

eod: end of data

Reads as: eod is "end of data": there is no data at this point, because the point is outside the data.

Means: a point is eod past an input's data, outside a bound, below 0, and wherever a program writes eod. Inside the data, a point with no usable value is never eod: it is missing data.

Example:

-- file eod.el8
-- Where eod arises: past the last row, below 0, outside a bound, and where the program says so.
reading = input("reading", t : inf)
change = reading - reading[t = #t - 1]
ended = iseod(reading)
first_two = restrict reading to (t : 2) end
none = eod
both = eod + error("sensor fault")
-- table reading = t,value,ts; 0,4,1000; 1,7,2000; 2,5,3000
-- expect reading[t = 3] = eod
-- expect ended[t = 3] = true
-- expect change[t = 0] = eod, at time 1000 ms
-- expect change[t = 1] = 3, at time 2000 ms
-- expect first_two[t = 2] = eod
-- expect none = eod
-- expect both = eod

Open in playground

Answers:

pointkindtimestampwhy
reading[t = 3]eod0past the last row along t, declared inf
ended[t = 3]data: true0iseod tests for eod
change[t = 0]eod1000 msreading[t = -1] is below 0; the timestamp is that of reading[t = 0], also read
change[t = 1]data: 32000 ms7 − 4
first_two[t = 2]eod0outside the bound t : 2
noneeod0the program writes eod
botheod0eod wins over an error

Check:

  1. eod where you expected data: is the point past the data's last row, outside a bound, or below 0? elucid8 info lists each value's dimensions and bounds.
  2. eod at every point: a search by time compared a position with a time (asof.q quote at #t end), or the data begin later than the program reads. Query the first point and press Why?.

Rules:

  1. eod arises only in these places: past the last row along an input's dimension declared inf (Where data ends); outside an input's bound or list; outside a restrict … to … end; at a coordinate below 0; and where the program writes eod.
  2. Operators and functions are strict: an operand that is eod makes the result eod. if, and, or and fby look only at the operands they use.
  3. eod wins over an error: where an operator's operands include eod and an error, the result is eod.
  4. eod has timestamp 0 where it arises, and takes the timestamp of everything read where it is passed on.
  5. iseod(e) is true where e is eod and false elsewhere. default(e, v) is v where e is eod and e elsewhere.
  6. A data file holds eod only as the last row of a line along a dimension declared inf (a cell eod). Inside a fixed range the reader refuses an eod cell (What is refused).
  7. A query that leaves out a dimension of its value gives eod at every point, with a warning naming the dimension. From 0.26.0 such a query is refused (What is refused).

Tested by data-ends-finite, data-ends-c4 and dc7-restrict.

Errors

Reads as: an error is an answer that says what went wrong and where it started.

Means: an error has an error kind and an origin. Operators pass it on unchanged, so the error at an answer is the error at its origin.

Example:

-- file error-kinds.el8
-- Errors a program makes, the origin an error keeps, and testing and filling by kind.
reading = input("reading", t : 4)
ratio = 10 / reading
doubled = ratio * 2
big = exp(reading * 1000)
positive = reading assert reading > 0
fault = restrict if #t == 3 then error("sensor fault") else reading to (t : 4) end
nothing = mean reading over (t : 3 .. 2) end
is_division = iserror(doubled, "division")
safe = default(doubled, 0, "division")
-- table reading = t,value; 0,2; 1,0; 2,-1; 3,5
-- expect doubled[t = 0] = 10
-- expect ratio[t = 1] = error division: division by zero
-- expect doubled[t = 1] = error division from ratio[t = 1]: division by zero
-- expect big[t = 0] = error non-finite: exp gave Infinity (non-finite)
-- expect positive[t = 2] = error assert: assert failed: reading > 0 was false
-- expect fault[t = 3] = error raised: sensor fault
-- expect nothing = error empty: mean of no elements
-- expect is_division[t = 1] = true
-- expect safe[t = 1] = 0

Open in playground

Answers:

pointkinderror kindorigin
doubled[t = 0]data: 10
ratio[t = 1]errordivisionratio[t = 1]
doubled[t = 1]errordivisionratio[t = 1] (read through one link)
big[t = 0]errornon-finitebig[t = 0]
positive[t = 2]errorassertpositive[t = 2]
fault[t = 3]errorraisedfault[t = 3]
nothingerroremptynothing
is_division[t = 1]data: true
safe[t = 1]data: 0

The error kinds:

error kindwhere it arises
missingan input's point inside the data with no usable value (Missing data)
latean input answered on demand answered after its deadline (Data services)
failedan input answered on demand failed (Data services), or an input's connector failed
divisiondivision by zero (/, div, mod)
non-finitean operation whose result is infinite or not a number
emptymean, min, max, argmax, argmin or a statistic of no elements (Aggregates); head or tail of the empty list
asserte assert p where p is false or eod
typea value of the wrong sort where it is used: 1 + "a", if 3 then …, not 1, a coordinate or bound that is not one
indexa list position before the start or past the end of the list (L elt 5), or a record without the field
dataa data file's error: … cell, or an error read back from a file that does not carry its kind
raisederror("…") written in the program
versionthe version of an input that a pinned query asks for is no longer available

Check:

  1. Which error kind? Test it with iserror(e, "division"). A program that fills errors fills one kind at a time, default(e, v, "division"), so the other kinds still show.
  2. Where did it start? The origin. doubled[t = 1] above did not divide; ratio[t = 1] did.

Rules:

  1. Operators and functions are strict: an operand that is an error makes the result that error, keeping its error kind and its origin. Of two errors among an operator's operands, the first in the order written is the result. eod wins over an error.
  2. iserror(e) is true where e is an error; iserror(e, k) where it is an error of kind k. Both give data with e's timestamp. k is a text written in place, one of the eight error kinds; anything else is refused by the compiler.
  3. default(e, v, k) is v where e is an error of kind k (or, with k written "eod", where e is eod), and e everywhere else. To fill eod and missing data both: default(default(e, v), v, "missing").
  4. An error's timestamp is the latest of what it read, as for data.

Tested by error-kinds, long-chain and strict-detector-0.

Missing data

Reads as: missing data is "a reading that should be here, and is not".

Means: missing data is an error of kind missing. It arises only where an input is read, at a point inside the data with no usable value.

Example: the triple above: reading has no row at t = 2 and an empty cell at t = 1, so both are missing data, and doubled there is that error, from reading.

Rules:

  1. Missing data arises at these points, each with the message input reading has no data at this point (the input's name), and the timestamp given:
    • a point with no row, inside the data: timestamp 0, because it has no time;
    • an empty or null cell (an empty CSV field, JSON null, an Arrow or Parquet null, SQL NULL; pandas None and NA through the Python package): its row's time;
    • a point with no row on an input whose times come from a clock ("time": {"dimension": "hour", "everyMs": 3600000}): the time its clock gives that point (below), 0 at a tick whose clock time is 0, which is a time like any other;
    • an input answered on demand that answers "nothing here": timestamp 0.
  2. Missing data is an error like any other: operators pass it on, iserror(e, "missing") tests it, default(e, v, "missing") fills it, and a deployment can fill it with fill.
  3. Aggregates leave missing data out and count it (Aggregates). A search takes it as a candidate only when it has a time (Direct reads and searches).
  4. Written to CSV, the value cell of missing data is empty and its kind column says error missing, so the file reads back as written; eod's kind column says eod, and another error's its kind (error division), with the cause in the message column. With --csv-words, the value column alone: missing data an empty field, eod eod, every other error error: ….

A clocked input. With times from a clock, a point with no row is missing at its clock time: the reading was due then, and nothing came.

temp = input("temp", hour : 6)
day_total = sum temp over (hour : 6) end

temp.csv:

hour,value
0,10
1,11
3,13

deploy.json:

{
  "format": "elucid8-deploy/2",
  "inputs": {
    "temp": { "from": "temp.csv", "time": { "dimension": "hour", "everyMs": 3600000 } }
  }
}

elucid8 run --query 'temp[hour = 2]' --query day_total gives:

elucid8 run: warning: query 2 (day_total): aggregates left out 3 missing points of input temp
{"name":"temp","context":{"hour":2},"outcome":{"kind":"error","error":"missing","message":"input temp has no data at this point","origin":{"name":"temp","context":{"hour":2}},"ts":7200000}}
{"name":"day_total","context":{},"outcome":{"kind":"value","value":34,"ts":18000000}}
pointkindvaluetimestamp
temp[hour = 1]data113,600,000 ms (hour 1)
temp[hour = 2]errormissing, from temp[hour = 2]7,200,000 ms (hour 2)
temp[hour = 4], temp[hour = 5]errormissinghours 4 and 5
temp[hour = 6]eod0: outside the bound hour : 6
day_totaldata3418,000,000 ms: hours 2, 4 and 5 left out, and counted

Tested by column-gap-time-zero, clock-gap-asof, clock-gap-window, clock-gap-default and dropouts.

Data services: late and failed

Means: an input answered on demand (a model, a web API, a simulated service) gives an error of kind late when its answer comes after its deadline, and of kind failed when it fails. The error's timestamp is when the call ended: the deadline, or the failure.

Example:

-- file service-kinds.el8
-- A service that answers too late, and one that sometimes fails.
reading = input("reading", t : 4)
model = input("model", n : inf)
score = model[n = reading]
flaky = input("flaky", n : inf)
checked = flaky[n = reading]
was_late = iserror(score, "late")
did_fail = iserror(checked, "failed")
-- data reading = 10 * #t
-- service model: answers formula x1; takes 30 ms; deadline 20 ms
-- service flaky: answers formula x1; takes 5 ms; fails 50% with overloaded; seed 5; deadline 20 ms
-- expect score[t = 1] = error late from model[n = 10]: late (30 ms > deadline 20 ms), at time 20 ms
-- expect was_late[t = 1] = true, at time 20 ms
-- expect checked[t = 0] = 0, at time 5 ms
-- expect checked[t = 1] = error failed from flaky[n = 10]: service error: overloaded, at time 5 ms
-- expect did_fail[t = 1] = true, at time 5 ms

Open in playground

Rules: a service's deadline, retries and reuse are its settings (Data services). A late answer is never a value. Each attempt is recorded, and a recorded run replays exactly.

Tested by job-services and services-v02.

Where data ends

Reads as: along a dimension declared inf, the data say where they end; inside a fixed range or a list, every point is a reading that should be there.

Means: whether a point with no row is eod or missing depends on how the input declares the dimension: past the data's end it is eod; inside the data it is missing.

Example:

-- file data-ends.el8
-- The same rows over t declared inf, over t : 5 and over a list.
open = input("open", t : inf)
fixed = input("fixed", t : 5)
listed = input("listed", t : {0, 1, 3, 7})
-- table open = t,value; 0,1; 1,2; 3,4
-- table fixed = t,value; 0,1; 1,2; 3,4
-- table listed = t,value; 0,1; 1,2; 3,4
-- expect open[t = 2] = error missing: input open has no data at this point
-- expect open[t = 4] = eod
-- expect fixed[t = 4] = error missing: input fixed has no data at this point
-- expect fixed[t = 5] = eod
-- expect listed[t = 7] = error missing: input listed has no data at this point
-- expect listed[t = 2] = eod

Open in playground

Answers:

pointkindwhy
open[t = 2]error missinga gap among the rows, before the last row along t (t = 3)
open[t = 4]eodpast the last row along t
fixed[t = 4]error missinginside t : 5, which has no end of data
fixed[t = 5]eodoutside the bound
listed[t = 7]error missingin the list, with no row
listed[t = 2]eodnot in the list

Rules:

  1. Every dimension of an input says its extent: t : inf (the data decide where it ends), t : 10 or t : 3 .. 9 (a fixed range), or t : {…} (a list of numbers or texts). A dimension named alone is refused by the compiler.
  2. Data end only along a dimension declared inf whose coordinates are whole numbers. Along such a dimension t, the last row along t is the greatest coordinate the input's data list along it (a row whose value cell is empty counts). A point with no row past it is eod, timestamp 0.
  3. Every other point with no row, inside the bound and lists, is missing data. So a gap among the rows is missing; along t : inf the points after the last row are eod; inside t : 10 they are missing.
  4. The last row is the input's, over all its lines. A sensor that missed the last reading has missing data there, because another sensor's row reaches it (Direct reads and searches).
  5. "ragged": true in the input's entry in deploy.json makes each line (the input's other coordinates fixed) end at its own last row along each dimension declared inf, for data whose lines have different lengths. A line with no row ends before 0. It is refused on an input with no dimension declared inf.
  6. Along a dimension of texts or real numbers there is no order of rows and so no end: a coordinate the data do not list is missing data, inside its list.

An input with no rows (an empty file, or a header only) needs no rule of its own. Along a dimension declared inf, every point is past the end, so eod. Inside a fixed range, every point is a reading that should be there, so missing data.

pen = input("pen", t : inf)
box = input("box", t : 3)

With pen.csv and box.csv each holding only the header t,value, pen[t = 0] is eod, and box[t = 0] to box[t = 2] are missing data. elucid8 check warns about both:

  warning: input "pen" has no rows (pen.csv): every point is eod along t, declared inf
  warning: input "box" has no rows (box.csv): every point inside its bounds is missing data

The playground differs in one case: an input whose card has no rows at all is an error at every point, so that a misspelt input answered on demand says so.

Tested by data-ends-finite, data-ends-ragged, data-ends-q47, data-ends-c4 and data-ends-fill.

Filling gaps: fill

Reads as: "fill": {"missing": 0} is "where this input has no reading inside the data, read 0".

Means: fill is a setting of an input, in its entry in deploy.json. Every point of the input that is missing data where it is read reads the value given instead. A filled point is data.

Example: sales is filled with 0 ("fill": {"missing": 0} in deploy.json; the line -- fill sales = 0 gives the same setting here), raw is the same rows without a fill.

-- file fill.el8
-- The same rows with a fill of 0, without one, and filled in the program.
sales = input("sales", day : inf)
raw = input("raw", day : inf)
n = count sales over (day : 0 .. 3) end
n_raw = count raw over (day : 0 .. 3) end
total = sum sales over (day : 0 .. 3) end
total_raw = sum raw over (day : 0 .. 3) end
in_program = default(raw, 0, "missing")
-- table sales = day,value; 0,5; 2,7; 3,1
-- table raw = day,value; 0,5; 2,7; 3,1
-- fill sales = 0
-- expect sales[day = 1] = 0
-- expect sales[day = 4] = eod
-- expect raw[day = 1] = error missing: input raw has no data at this point
-- expect n = 4
-- expect n_raw = 3
-- expect total = 13
-- expect total_raw = 13
-- expect in_program[day = 1] = 0
-- expect in_program[day = 4] = eod

Open in playground

Answers:

pointanswerwhy
sales[day = 1]0no row inside the data: the fill
sales[day = 4]eodpast the last row along day: a fill never reaches past the data
raw[day = 1]error missingno fill
n, n_raw4, 3a filled point is counted; a missing one is left out (with a warning)
total, total_raw13, 13adding 0 changes no sum
in_program[day = 1]0default(…, "missing") in the program gives what fill gives

Check: a fill hides gaps. Ask whether a missing reading means "nothing happened" (a fill of 0 is right: no sales that day) or "we do not know" (leave fill out: an aggregate then says how many it left out).

Rules:

  1. "fill": {"missing": v}: v is a number, true, false or a text ("0" is the text 0), or an object by coordinate of one of the input's dimensions declared with a list or a count, {"missing": {"kind": 0, "key": ""}}, where "*" names every coordinate not named, and a coordinate not named with no "*" stays missing data.
  2. Leaving fill out is the default: a point with no row inside the data is missing data.
  3. A filled point is data: operators combine it, aggregates count and fold it, and searches and windows take it as a candidate. iserror(x, "missing") is false there.
  4. A fill keeps the timestamp of what it fills: on a clocked input, the clock's time at that point; an empty cell, its row's time; otherwise 0. default(x, v, "missing") in the program gives the same timestamps.
  5. A fill reaches only points inside the data. Past the last row along a dimension declared inf (with "ragged": true, past each line's own last row) a point is eod, whatever fill says.
  6. missing is the only kind a deployment fills. eod is end of data, never filled by a deployment (default(x, v) in the program gives a value past the data); other errors are the program's to fill (default(x, v, "late")).

Tested by fill-plain, fill-by-coordinate, data-ends-fill, clock-gap-default and the fill-sparse-… cases.

Aggregates

Reads as: sum reading over (t : 6) end is "the sum of reading over t from 0 to 5, missing points left out".

Means: every aggregate (over a region, a neighbourhood or a window) leaves out its missing elements, and counts them. If every element it had was missing, the result is missing. With no elements at all, it gives its ordinary answer: 0, or an error of kind empty where there is none.

Example:

-- file aggregates.el8
-- Sums and counts over readings with gaps, and over nothing.
reading = input("reading", t : 6)
total = sum reading over (t : 6) end
quiet = sum reading over (t : 6) skip missing end
n = count reading over (t : 6) end
gaps = sum (if iserror(reading, "missing") then 1 else 0) over (t : 6) end
all_missing = sum reading over (t : 2 .. 3) end
none = sum reading over (t : 3 .. 2) end
none_mean = mean reading over (t : 3 .. 2) end
-- table reading = t,value,ts; 0,1,1000; 1,2,2000; 4,5,5000; 5,6,6000
-- expect total = 14, at time 6000 ms
-- expect quiet = 14, at time 6000 ms
-- expect n = 4, at time 6000 ms
-- expect gaps = 2, at time 6000 ms
-- expect all_missing = error missing from reading[t = 2]: input reading has no data at this point
-- expect none = 0
-- expect none_mean = error empty: mean of no elements

Open in playground

Answers:

pointanswerwhy
total14, at 6000 ms1 + 2 + 5 + 6; t = 2 and 3 left out, with the warning aggregates left out 2 missing points of input reading
quiet14, at 6000 msthe same answer; skip missing written, so no warning
n4count counts the elements kept
gaps2missing points are counted with iserror, never with count
all_missingerror missing, from reading[t = 2]every element was missing: the first of them
none0no elements: the ordinary sum
none_meanerror emptythe mean of no elements has no answer

Rules:

  1. An aggregate leaves out each element that is missing data: not counted, not folded, its timestamp still counted. mean and count are over what is kept.
  2. A query counts the missing points its aggregates left out, each point once, and reports them per input in a warning (aggregates left out 3 missing points of input reading) and in skippedMissing in the query's report (elucid8 run --report, serve's replies).
  3. skip missing written on an aggregate makes it quiet: the same answer, the points still counted in skippedMissing, but not in the warning.
  4. If every element it had was missing, the result is missing: the first missing element in the aggregate's order, with the aggregate's timestamp.
  5. With no elements at all: sum, approx_sum and count give 0, list gives [] and collect {}; mean, approx_mean, min, max, argmax, argmin, variance, sample_variance and stddev give an error of kind empty (mean of no elements), which iserror(x, "empty") tests and default(x, v, "empty") fills. sample_variance of one element is an error of kind failed (sample variance of one element).
  6. An aggregate's elements are the points it would fold: not the positions a filter leaves out, not the positions past a bound or below 0, and, with skip eod, not the eod ones.
  7. Otherwise an eod element makes the result eod (eod wins), unless skip eod is written; and another error element makes the result that error, the first in the aggregate's order.
  8. A window takes missing data at its time like an aggregate: a clocked sensor that sent nothing in a window has only missing elements there, so the window's sum is missing; an input with a time column and no rows in the window has an empty window, so its sum is 0.
  9. To leave errors out of an aggregate, filter them: if not iserror(temp) after the region, or if not iserror(temp, "data") for one error kind. eod is never a marker for "leave this out": if iserror(temp) then eod else temp says the data end where a reading was faulty, and every reader of that value sees an end of data there.

Leaving out errors: missing points are left out by themselves; other errors only where the program filters them out.

-- file faulty.el8
-- The mean of 8 readings: an empty cell at t = 2, no row at t = 4, a fault at t = 6.
temp = input("temp", t : 8)
all = mean temp over (t : 8) end
clean = mean temp over (t : 8) if not iserror(temp) end
-- table temp = t,value; 0,15; 1,15.5; 2,; 3,16.5; 5,17; 6,error: sensor fault; 7,18
-- expect all = error data from temp[t = 6]: sensor fault
-- expect clean = 16.4

Open in playground

pointanswerwhy
allerror data, from temp[t = 6]the two missing points left out, with a warning; the fault is the first error left, so it is the result
clean16.4the mean of the five readings: the filter leaves out the fault and the two missing points, so there is no warning

Tested by gaps-skipped-counts, skip-missing-quiet, aggregate-region-all-missing, aggregate-region-empty, aggregate-window-clock-all-missing, aggregate-window-clock-one-reading and aggregate-window-column-empty.

Direct reads and searches

Reads as: a direct read, reading[sensor = 1, t = 3], asks "is there a reading here?". A search, asof.t reading[sensor = 1] at 3500 end, asks "what has arrived on this line, as of 3500?".

Means: a direct read of a point inside the data with no row gives missing data. A search along a dimension declared inf looks only as far as its own line's data have arrived: up to that line's last row.

Example: sensor 0 has rows to t = 3, sensor 1 only to t = 1. kept holds the same rows, with "ragged": true (the line -- ragged kept here).

-- file lines.el8
-- A line that stops early: read directly, searched, and read as ragged.
reading = input("reading", sensor : 2, t : inf)
kept = input("kept", sensor : 2, t : inf)
now_1 = reading[sensor = 1, t = 3]
known_1 = asof.t reading[sensor = 1] at 3500 end
last_1 = latest.t reading[sensor = 1] at 3500 end
ragged_1 = kept[sensor = 1, t = 3]
-- table reading = sensor,t,value,ts; 0,0,10,0; 1,0,20,0; 0,1,11,1000; 1,1,21,1000; 0,2,12,2000; 0,3,13,3000
-- table kept = sensor,t,value,ts; 0,0,10,0; 1,0,20,0; 0,1,11,1000; 1,1,21,1000; 0,2,12,2000; 0,3,13,3000
-- ragged kept
-- expect now_1 = error missing from reading[sensor = 1, t = 3]: input reading has no data at this point
-- expect known_1 = 21, at time 1000 ms
-- expect last_1 = 1, at time 1000 ms
-- expect ragged_1 = eod
-- expect reading[sensor = 1, t = 4] = eod

Open in playground

Answers:

pointanswerwhy
now_1error missing, from reading[sensor = 1, t = 3]inside the data (sensor 0's row reaches t = 3), and sensor 1 has no row there
known_121, at 1000 msthe search on sensor 1's line stops at its last row, t = 1
last_11latest gives the position: sensor 1's last row
ragged_1eodwith "ragged": true, sensor 1's line ends at its own last row
reading[sensor = 1, t = 4]eodpast the input's last row along t

The difference between now_1 and known_1 is intended. A direct read asks about one point, and a reading due there that did not come is missing. A search asks what has arrived on a line, and a feed that has not reported yet has not sent anything to find.

Searches over a gap (asof, hold, latest, after):

-- file search-gaps.el8
-- An empty cell with a time is a candidate; a point with no row is not.
quote = input("quote", q : 4)
at_gap = asof.q quote at 9500 end
known = asof.q quote at 9500 skip missing end
early = asof.q quote at 500 end
-- table quote = q,value,ts; 0,100,1000; 1,101,4000; 2,,6000
-- expect quote[q = 3] = error missing: input quote has no data at this point
-- expect at_gap = error missing from quote[q = 2]: input quote has no data at this point, at time 6000 ms
-- expect known = 101, at time 4000 ms
-- expect early = eod

Open in playground

pointanswerwhy
quote[q = 3]error missing, timestamp 0no row inside q : 4
at_gaperror missing, from quote[q = 2], at 6000 msthe empty cell at 6000 is the latest candidate; q = 3 has no time, so it is no candidate
known101, at 4000 msskip missing passes over the empty cell
earlyeodno candidate at or before 500

A stale hold: hold.t x at T within M end with no candidate in its window (T − M, T], but candidates both before it and after T (the readings stopped, then started again), is missing data: an error of kind missing (hold: no data within 2000 ms before 9000) at the time of the newest reading before the window. With readings at 1,000, 2,000 and 9,500 ms, hold.t x at 9000 within 2000 end is that error, at 2,000 ms. A window wholly before the first reading or after the newest is outside the data: eod. So a live answer, which reads the data present, gives eod for a stale hold at a stream's newest tick, and missing data at the same point once a later reading arrives. asof … within M and latest … within M are the same (asof: no data within …, latest: no data within …).

Rules:

  1. A direct read of an input (x[t = 4], or x at the current point) gives the row's value, missing data inside the data with no usable value, or eod outside the data (Where data ends).
  2. A search along a dimension declared inf reaches as far as the lines it reads have rows, at the same other coordinates: the earliest of those lines' last rows. A line that stops early is searched to its own last row, and other lines are not affected.
  3. A line the data never list has had nothing arrive: a search there gives eod.
  4. With a fill, the points after a line's own last row are not candidates of a search: a feed that has not reported yet is not read as zeros. A direct read of the same points gives the fill.
  5. Missing data with no time (a point with no row, timestamp 0, on an input with a time column or no times) is never a candidate, whether or not skip missing is written.
  6. Missing data with a time (an empty cell in a row with a time, or a point with no row on a clocked input, at its tick's time, 0 included) is a candidate at its time, an error like any other: the search's answer is that error when it is the candidate chosen, unless skip missing is written, which passes over it. skip eod passes over eod candidates.
  7. A window is an aggregate: it leaves out missing candidates always (Aggregates).
  8. A window over a line chosen at run time counts the read that picks the line in each element's time, written inline or through a named value alike. It follows from the general rule that a value's time includes what chose it: quotes[sym = trade_sym] is stamped with the later of the quote's time and trade_sym's. In count quotes[sym = trade_sym] over (q : window.q 60000 at time(trade_sym)) end, each quote is judged at the later of its own time and the trade's. With A's quotes at 1,000, 50,000 and 80,000 ms and a trade of A at 100,000 ms, the count is 3, stamped 100,000 ms, and so is count picked over … end with picked = quotes[sym = trade_sym]: naming a part of a program never changes its answer. To judge each element by its own time, aggregate first, then select: (count quotes over (q : window.q 60000 at time(trade_sym)) end)[sym = trade_sym] gives 2, stamped 100,000 ms, as does the window over the line named, count quotes[sym = "A"] over … end. The same holds for hold … within M: hold.q quotes[sym = trade_sym] at time(trade_sym) within 10000 end gives 12 (the quote at 80,000 ms, judged at 100,000), while hold first, then select, (hold.q quotes at time(trade_sym) within 10000 end)[sym = trade_sym], gives eod (no quote of A in the 10 s before the trade). asof and latest have no lower edge and give the same answer either way. The law: selecting a line commutes with a window or within when the index's timestamp is 0 (a constant or a coordinate).
  9. From 0.26.0, time(e) has e's bounds, so a search over it is accepted where a search over e is: with quotes at 1,000, 2,500 and 4,000 ms over q : inf, asof.q time(quotes) at 3000 end gives 2,500. Releases before 0.26.0 refuse it (v must be bounded along q).

Tested by gaps-search-window, gaps-hold-skip-missing, clock-gap-asof, column-gap-time-zero, reach-chosen-missing, reach-chosen-trades, chosen-line-substitution and fill-sparse-searches.

What is refused

A mismatch between a program and its setup is not a gap in the data. It is refused where it is read, with a message naming what to change, and no answer is computed.

  1. A file that does not fit the program. A file with no column (CSV) or field (JSON lines) named after one of an input's dimensions, and a file for an input with no dimensions that holds other than one value, are refused by elucid8 check, run and serve (exit code 3). For temp = input("temp", hour : 6) and a file with columns t,value:

    elucid8: input temp (temp.csv): no column hour, a dimension of temp; its columns are t, value
  2. "missing" in an input's entry. The setting is fill; "missing" is refused with the form to write:

    elucid8: deploy.json: inputs.temp.missing: write "fill": {"missing": 0}, not "missing"
  3. A fill of eod. eod is end of data, never a fill:

    elucid8: deploy.json: inputs.temp.fill.eod: eod is end of data, never filled here. For points with no row inside the data, write "fill": {"missing": 0}; past the data, write default(temp, 0) in the program
  4. An eod cell inside a fixed range, or anywhere but the last row of a line along a dimension declared inf.

  5. From 0.26.0, a query that leaves out a dimension of its value (grid[x = 0] for a grid over x and y) is refused, naming the dimension. Releases before 0.26.0 give eod at every point with a warning.

The Command reference gives every message.

Summary

kindmeanswhere it arisesin an aggregatein a searchtest withfill with
eodthe point is outside the datapast the last row along inf; outside a bound or list; below 0; eodthe result is eod, unless skip eodno candidateiseod(x)default(x, v) in the program
missing (an error)a reading inside the data is not thereno row inside the data; an empty cell; "nothing here"left out and counted; all missing: missinga candidate only with a time; skip missing passes over itiserror(x, "missing")"fill" in deploy.json, or default(x, v, "missing")
other errorssomething went wrong, at its originlate, failed, division, non-finite, empty, assert, type, index, data, raised, versionthe first in order is the result; if not iserror(x) after the region leaves them outthe candidate chosen gives itiserror(x, "late"), …default(x, v, "late"), …

How answers are written

The same triple, for doubled in the triple example, by elucid8 run as JSON lines:

{"name":"doubled","context":{"t":0},"outcome":{"kind":"value","value":8,"ts":1000}}
{"name":"doubled","context":{"t":1},"outcome":{"kind":"error","error":"missing","message":"input reading has no data at this point","origin":{"name":"reading","context":{"t":1}},"via":{"length":1,"path":[{"name":"reading","context":{"t":1}}]},"ts":2000}}
{"name":"doubled","context":{"t":5},"outcome":{"kind":"eod","ts":0}}

and as CSV, with --timestamps:

name,t,doubled_value,doubled_kind,doubled_message,doubled_ts
doubled,0,8,value,,1000
doubled,1,,error missing,input reading has no data at this point,2000
doubled,2,,error missing,input reading has no data at this point,0
doubled,3,12,value,,3000
doubled,4,4,value,,4000
doubled,5,,eod,,0
written askinderror kind and origintimestamp
JSON lines (run, serve, the MCP tools' rows)outcome.kind: value, eod or erroroutcome.error, the error kind (missing, late, failed, division, non-finite, empty, assert, type, index, data, raised, version), with message; origin, the point where it started, as {"name", "context"}ts, always written
CSV<value>_kind: value, eod, or error and its kind (error missing); <value>_value holds data only<value>_kind and <value>_message; <value>_origin with --triple<value>_ts, with --timestamps
Arrow, Parquet, NumPy, Zarr, frames<value>_kind: 0 data, 1 eod, 2 error<value>_error, the error's record as JSON (error, message, origin, detail, via)<value>_ts
the playgroundthe answer line: the value, eod, or Error via reading[t = 1]: …in the wordstimestamp … ms under the answer

Output formats gives each format in full.