icicle-lang / icicle-ambiata

A streaming query language.
BSD 3-Clause "New" or "Revised" License
57 stars 11 forks source link

Core evaluator should handle underflow/overflow for times #529

Open tranma opened 7 years ago

tranma commented 7 years ago
=== prop_psv_fission from test/Icicle/Test/Sea/PsvFission.hs:53 ===
*** Failed! (after 4 tests): 
Exception:
  Expected:
  maggie|gonzo|269369-01-07T07:41:19Z
  maggie|kermit|false
  marge|gonzo|269369-01-07T07:41:19Z
  marge|kermit|false

  Got:
  maggie|gonzo|17442-11-20T00:00:00
  maggie|kermit|false
  marge|gonzo|17442-11-20T00:00:00
  marge|kermit|false

  CallStack (from HasCallStack):
    error, called at test/Icicle/Test/Sea/PsvFission.hs:146:11 in main:Icicle.Test.Sea.PsvFission
InputType {unInputType = SumT ErrorT StringT}
well-typed:
  entities  = [maggie,marge]
  attribute = windy
  fact type = (Sum Error String)
  facts     = [AsAt {atFact = VRight (VString "maggie"), atTime = Time (1858 11 17 0 0 0s)},AsAt {atFact = VLeft (VError ExceptTombstone), atTime = Time (1858 11 18 0 0 0s)},AsAt {atFact = VLeft (VError ExceptTombstone), atTime = Time (1858 11 19 0 0 0s)}]
  time      = Time (1858 11 20 0 0 0s)
  core      =
    Program (gou virus0 : (Sum Error String), gou virus1 : FactIdentifier, gou virus2 : Time, gou virus3 : SNAPSHOT_TIME)
    Precomputations:
      camelpox0            = sub# (-0.2919623782963758) (0.26637770530658755)

    Streams:
      STREAM_FOLD (rotavirus0 : Bool)
        INIT:
          ge# (True) (True)
        KONS:
          True

    Postcomputations:
      chickenpox0          = fst# (((), 0))

    Returning:
      gonzo                = Time_minusMonths# gou virus3 (Time_secondsJulianEpoch# (2006-11-05T00:00:00Z))

  avalanche =
    gou virus3 = TIME
    let camelpox0 = sub# (-0.2919623782963758) (0.26637770530658755);
    init acc0$rotavirus0 = ge# (True) (True);
    load_resumable acc0$rotavirus0;

    for_facts (gou virus2, gou virus1, gou virus0) in new
    {
      write acc0$rotavirus0 = True;
    }
    save_resumable acc0$rotavirus0;

    read rotavirus0 = acc0$rotavirus0 [Bool];
    let chickenpox0 = fst# (((), 0));
    output gonzo (Time_minusMonths# gou virus3 (Time_secondsJulianEpoch# (2006-11-05T00:00:00Z)));
  flat      =
    gou virus3 = TIME
    for_facts (gou virus2, gou virus1, gou virus0$simp1, gou virus0$simp2, gou virus0$simp3) in new
    {

    }
    output gonzo (Time_minusMonths# gou virus3 (12833596800));
well-typed:
  entities  = [moe]
  attribute = freezing
  fact type = (Sum Error String)
  facts     = [AsAt {atFact = VRight (VString "lisa"), atTime = Time (1858 11 16 0 0 0s)},AsAt {atFact = VLeft (VError ExceptTombstone), atTime = Time (1858 11 17 0 0 0s)}]
  time      = Time (1858 11 17 0 0 0s)
  core      =
    Program (monkeypox0 : (Sum Error String), monkeypox1 : FactIdentifier, monkeypox2 : Time, monkeypox3 : SNAPSHOT_TIME)
    Precomputations:
      gou virus1           = sub# (-1) (1)

    Streams:

      STREAM_FILTER
        PREDICATE: 
          True
        STREAMS:

    Postcomputations:
      equine morbillivirus0
                           = round# (0.9227049013159824)

    Returning:
      kermit               = eq# (2030-12-15T00:00:00Z) (2014-12-16T00:00:00Z)

  avalanche =
    monkeypox3 = TIME
    let gou virus1 = sub# (-1) (1);

    for_facts (monkeypox2, monkeypox1, monkeypox0) in new
    {
      if (True)
      {

      }
    }

    let equine morbillivirus0 = round# (0.9227049013159824);
    output kermit (eq# (2030-12-15T00:00:00Z) (2014-12-16T00:00:00Z));
  flat      =
    monkeypox3 = TIME
    for_facts (monkeypox2, monkeypox1, monkeypox0$simp0, monkeypox0$simp1, monkeypox0$simp2) in new
    {

    }
    output kermit (False);
PsvConstants {psvMaxRowCount = 4, psvInputBufferSize = 35, psvOutputBufferSize = 35, psvFactsLimit = 4}
amosr commented 7 years ago

program boils down to

(Time_minusMonths# (1858 11 20 0 0 0s) (12833596800))

ie subtract an insane number of months from some 19th century date

which is going to underflow regardless. it's a bogus program. I don't know what we can do about this

tranma commented 7 years ago

yeah, this isn't our problem -- there is nothing to do here.

jacobstanley commented 7 years ago

We need to somehow make it so this doesn't fail intermittently.

Discussed IRL making the core evaluator detect this situation so we can discard the test.

amosr commented 7 years ago

For now I have modified the Core prim generator so it does not generate PrimTimeMinusMonths. It doesn't take many months to underflow a date, which means then the evaluators don't agree.

But a better solution might be using a consistent time representation between C and Core