Giter Club home page Giter Club logo

Comments (4)

kofrasa avatar kofrasa commented on July 19, 2024 1

Thanks for the bug report @Jaysok. Feel free to submit a PR.

Relevant code points.

https://github.com/kofrasa/mingo/blob/master/src/operators/accumulator/min.ts
https://github.com/kofrasa/mingo/blob/master/src/operators/accumulator/max.ts

Tests can be added here https://github.com/kofrasa/mingo/tree/master/test/operators/accumulator.

Thanks

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

After some consideration I don't think the behaviour should change as there is no reasonable way to address it except to error out. Unfortunately NaN yields weird results in most cases for almost all operators and this is no different. If NaN exists in your input data or can be generated in some intermediate process in the query, you should either cleanup the input or leverage the type conversion operators to convert before using for calculations.

MongoDB addresses this by failing operations that generate NaN results. I think that is a better way to address this on per operator basis.

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

An alternative I did not mention was to just make NaN inputs return NaN outputs but that just propagates the nonsense value through the process chain. This might be a better alternative since it can limit the useless values to only parts of some input data depending on what the query is doing. For example in window functions, some windows may contain NaN while others compute correctly.

from mingo.

kofrasa avatar kofrasa commented on July 19, 2024

I think it is best to retain behaviour that is consistent with other accumulator functions. NaN is too weird to work with and passing it through won't be useful. There are many more cases I can conceive where it is ok to ignore the NaN value in computations rather than pass it through. If there is demand to treat it some other way, I will consider putting that behind an option.

from mingo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.