Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing order and group #51

Open
vmx opened this issue Nov 21, 2017 · 1 comment
Open

Changing order and group #51

vmx opened this issue Nov 21, 2017 · 1 comment

Comments

@vmx
Copy link
Member

vmx commented Nov 21, 2017

I'd like to propose changing the language a bit to make it a bit more regular/consistent.

Order clause

Currently it is is:

order .baz asc default=1

I'd like to change it to:

order .baz default=1 asc

Reason: In return values it's:

return {baz: .baz default=0, hammer: .hammer default=1}

So it's (kind of like a tuple). Use this pattern for the order as well.

Grouping

Currently group() is:

group(.baz order=asc) default="a"

I'd like to change it to:

group(.baz default="a" asc)

Reason: It now has the same shape as the order clause.

What do others think about making this change?

vmx added a commit to vmx/noise that referenced this issue Dec 12, 2017
This change changes the recommend way of ordering the order clause

Instead of

    order .baz asc default=1

use

    order .baz default=1 asc

This makes the language more uniform. Paths with default values in
return values have the same shape (as they don't have an additional
asc/desc keyword).

This is related to pipedown#51.
@vmx
Copy link
Member Author

vmx commented Dec 13, 2017

The different order in the order clause is already support (both ways work), so it's just a matter of changing the documentation (which is done with #54).

For the grouping part, I wasn't aware that default values also work for other aggregates like max():

# Some data has {bar: 20} and some no value defined
find {}
return {max: max(.bar) default=1};
[
{"max":20}
]

Here the new syntax max(.bar default=120) makes even more sense. As the default a value is not the default of max(), but the default of the Keypath .bar in case that field doesn't exist.

vmx added a commit that referenced this issue Dec 14, 2017
This change changes the recommend way of ordering the order clause

Instead of

    order .baz asc default=1

use

    order .baz default=1 asc

This makes the language more uniform. Paths with default values in
return values have the same shape (as they don't have an additional
asc/desc keyword).

This is related to #51.
vmx added a commit to vmx/noise that referenced this issue Dec 14, 2017
Prior to this change, default values for aggregates were specified
as:

    max(.foo) default=5

The new syntax is putting the default value within the aggregate
function:

    max(.foo default=5)

This makes more sense as the default value is not a single value
for the `max()` function, but it is applied to every Keypath
*within* the `max()` function.

It is also more symmetrical to the default values for returns.
There it's also <Keypath> <space> <default>, e.g.:

    return .foo default=5

This is part of pipedown#51.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant