statisticsnorway / java-vtl

An Open Source Java implementation of the Validation Transformation Language, based on the VTL 1.1 draft specification. The implementation follows the JSR-223 Java Scripting API and exposes a simple connector interface one can implement in order to integrate with any data stores. VTL is a standard language for defining validation and transformation rules (set of operators, their syntax and semantics) for any kind of statistical data.
http://java-vtl.org
Apache License 2.0
21 stars 7 forks source link

Make round() returns a Number #52

Closed takvamborgen closed 6 years ago

takvamborgen commented 6 years ago

If rounding to zero decimals, a Number with int value is returned, otherwise a Number with double value

codecov[bot] commented 6 years ago

Codecov Report

Merging #52 into develop will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop      #52   +/-   ##
========================================
  Coverage    77.33%   77.33%           
========================================
  Files          133      133           
  Lines         3305     3305           
  Branches       379      380    +1     
========================================
  Hits          2556     2556           
  Misses         635      635           
  Partials       114      114
Impacted Files Coverage Δ
...ain/java/no/ssb/vtl/script/functions/VTLRound.java 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ea949be...7bbd411. Read the comment docs.

hadrienk commented 6 years ago

I changed this from VTLNumber to VTLFloat at some point since it caused problems in the type checking. Did you test that round() can be combined in a expression as follows?

test := 1 + round(10.5, 0)
takvamborgen commented 6 years ago

@hadrienk No. I assumed that since trunc() already returns a number, number as a function return type in expressions was supported. I should have tested that, of course. I will close this PR for now and look into it.