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

Is there a kind of "If/else" available in "eval" nodes? #603

Closed
jdursel opened this issue Jun 3, 2016 · 5 comments
Closed

Is there a kind of "If/else" available in "eval" nodes? #603

jdursel opened this issue Jun 3, 2016 · 5 comments

Comments

@jdursel
Copy link

jdursel commented Jun 3, 2016

Hello,

I would like to do something like if/else to store a state in a new output measurement.

data
|eval(lambda: if "value" gt 18 then 1 else 0).as("active")

Is it possible?
Thank you
John.

Kapacitor "0.12"

@yosiat
Copy link
Contributor

yosiat commented Jun 3, 2016

@jdursel I think you can do something like this:

lambda: "value" > 18

Then active will be boolean.

@nathanielc
Copy link
Contributor

And if you want to use and int type instead of boolean just convert it:

lambda: int("value" > 18)

Which will output a 1 or 0 accordingly.

@jdursel
Copy link
Author

jdursel commented Jun 8, 2016

Hello,
Thank you for your answers. Unfortunately, this doesn't work.
The first one gives : expression returned unexpected type bool
The second one gives : error calling int: cannot convert bool to integer
I didn't try with float(), but i don't expect it to work better :-)

It is probably due to the version of kapacitor 0.12

@jdursel
Copy link
Author

jdursel commented Jun 8, 2016

I think it is the same kind of issue as : #501
Kr

@nathanielc
Copy link
Contributor

Correct the suggested solutions require 0.13 or greater. Also #501 should
be closed, as it was already implemented in 0.13.

On Wed, Jun 8, 2016, 1:41 AM jdursel notifications@github.com wrote:

I think it is the same kind of issue as : #501
#501
Kr


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#603 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ADmOAgFhas-FaPU7ysUwne2ZguU5hPrTks5qJnIJgaJpZM4ItaL5
.

Nathaniel Cook
Kapacitor Lead
https://influxdata.com

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

3 participants