influxdata / docs.influxdata.com-ARCHIVE

ARCHIVE - 1.x docs for InfluxData
https://archive.docs.influxdata.com/
MIT License
252 stars 292 forks source link

flow of if statements is missing information about when an if statement will stop #2878

Closed 8none1 closed 4 years ago

8none1 commented 4 years ago
URL for relevant page?

https://docs.influxdata.com/flux/v0.65/guides/conditional-logic/

What products and version are you using?

Flux

Where did you look before opening the issue?

Docs and Slack

The if statement will stop on the first match, and as the Flux team describes it "short circuit when possible". For example, given this Flux:

|> map(fn: (r) => ({ // Retain all existing columns in the mapped row r with // Set the level column value based on the _value column level: if r._value >= 95.0000001 then "critical" else if r._value >= 85.0000001 "warning" else if r._value >= 70.0000001 then "high" else "normal" })

Where r._value is 96, then the output would be "critical" because the if statement would match on the first line and then stop.

While this is possible to test and work out I think it should be explicitly mentioned in the docs.