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

Proposal: scalar functions similar to vector #4558

Open
Armatorix opened this Issue Aug 29, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@Armatorix
Copy link

Armatorix commented Aug 29, 2018

Proposal

Now when you want to make some functions like floor, round, ceil, etc. on scalar you've got to firstly change it to vector than make some functions on it and change it back to scalar. IMO it would be better to have also functions directly on scalars.
Example:

  • now: scalar(round(vector(time())))
  • request: round(time())
    Or I'm missing some feature or concept?

@Armatorix Armatorix changed the title Propsal: scalar functions similar to vector Proposal: scalar functions similar to vector Aug 29, 2018

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Aug 29, 2018

This was something I specifically avoided when considering PromQL changes, as overloading functions makes them harder to understand - particularly if the output type varies too as you seem to be proposing. Instead if you've a different type of input, you get a different function (e.g. avg_over_time vs avg). Once you do that any benefits are quite a bit smaller.

@Armatorix

This comment has been minimized.

Copy link
Author

Armatorix commented Aug 29, 2018

You're probably right with overloading.
Maybe referring to existing functions, prometheus could have floor_scalar, round_scalar, etc. ? Then there will be no overloading, also in some cases sytax should be less complex and ofc performance benefits.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Aug 29, 2018

That seems like it'd be a bit much clutter in the language for something that's already possible. The performance differences here are negligible, we're only talking doing math on a single value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.