Code Monkey home page Code Monkey logo

Comments (6)

lastlegion avatar lastlegion commented on July 16, 2024 1

Yes I agree the documentation is really good!
I'm not sure about this particular case, if this is the desired behavior. I'll keep it open for @vogievetsky to comment on.

from plywood.

robertervin avatar robertervin commented on July 16, 2024

@lastlegion Could you post your query (make it more generic if you need to)?

You should be running collect on a DATASET type object. It will hit https://github.com/implydata/plywood/blob/master/src/expressions/baseExpression.ts#L1431 to use a CollectExpression

I may be able to help out more if I understand your exact query.

from plywood.

lastlegion avatar lastlegion commented on July 16, 2024

I've been trying different variants of the following query:

var ex4 = ply().apply("d", $("dataset").filter($("field2").in(0,1)))
        .apply("dd2", $("d").collect("$field2"))

or

var ex4 = ply().apply("d", $("dataset").filter($("field2").in(0,1)))
        .apply("dd", $("d").select("field1", "field2"))
        .apply("dd2", $("dd").collect("$field2"))

and I get the following error:

(node:55886) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: unsupported aggregate action $__SEGMENT__:DATASET.collect($HR:NUMBER) (as __VALUE__)

I tried replacing collect with other aggregation functions like count etc. and was able to get the right results. Thanks @robertervin for your help!

from plywood.

robertervin avatar robertervin commented on July 16, 2024

@lastlegion You're completely correct on this. I also ran into this issue when I tried running it.

What you want to do instead is first split by field2. This will issue a groupBy query to Druid, which is much more efficient than pulling all field2 values into memory in javascript then making them distinct.

So your first query would turn into

var ex4 = ply()
    .apply("d", $("dataset")
        .filter($("field2").in(0,1))
    )
    .apply("dd2", $("d")
        .split({id: "$field2"})
        .collect("$id")
    )

Perhaps @vogievetsky may be able to shed some light on why Plywood doesn't perform this by default, or if my logic on the reasoning is correct.

from plywood.

lastlegion avatar lastlegion commented on July 16, 2024

Thanks for your help! Yes I'm able to the desired output by applying .split() before .collect(). Yes if this is a bug then I'm willing to put in a pull request or help with documenting it.

from plywood.

robertervin avatar robertervin commented on July 16, 2024

@lastlegion You're welcome! I'm not actually a member of Imply, so I can't accept any PRs or anything. I do think the documentation is fairly good, but could could definitely be improved.

You can try submitting a PR for it in https://github.com/implydata/plywood/blob/master/docs/expressions.md and calling out @vogievetsky (who I believe is the sole owner of this codebase).

Would appreciate if you could close this issue as well since it's fixed.

from plywood.

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.