InseeFr/Trevas

Sqrt

NicoLaval opened this issue · 5 comments

Sqrt throws errors for calls with null / NaN / negative values, BdI tests assume null to be the correct result.

@noahboerger

  • NaN : sqrt only admits number as parameter, seems to be the good behaviour to throw an exception
  • negative: Trevas bug , has to return value
  • null:
    • scalars : sqrt(null) null has no inferred type, you have to write sqrt(cast(null, number))
    • components / datasets:
      Considering ds_1 := ds[calc sq := sqrt(a)]; and ds:
id a
IDENTIFIER MEASURE
INTEGER INTEGER
1 2
2 -2
3 null

Trevas ds_1 result will be:

id a sq
IDENTIFIER MEASURE MEASURE
INTEGER INTEGER INTEGER
1 2 4
2 -2 4
3 null null

Thanks to dataset metadata, null is recognized as integer.

TODO: fix behaviour for negative inputs

Thank you for the explanations and plan to fix it for negative inputs.

Just a comment here, but I think I've seen somewhere in the spec that type inference should be supported. It's a very small paragraph and there's not much details. Technically I think this isn't too hard to implement and has great value for the users. But this need to be reworked in the spec.

Not sure about that.
What will be rewrited in 2.1 is implicit casting between known types.

I think your right, when there is no doubt about the null type, we can apply an implicit cast, avoiding users to write lot of cast.

I opened an issue in the TF repo