How do I print scalar variables in VSCode Flux extension?

dueDate = 2019-05-01
overdue = if dueDate < now() then true else false

If I want to run the above in flux script in VScode, how do I print the ‘overdue’ variable to the console for debugging purposes?

I just get the error:
Error: error in query specification while starting program: this Flux script returns no streaming data. Consider adding a “yield” or invoking streaming functions directly, without performing an assignment

Thanks,
MPH

Hi there,
So essentially Flux is expecting you to define a yield in order to display the input table which is considered the result of your query. Propose we take your example:

import "array"

data = array.from(rows: [{_time: 2021-09-23T15:58:02.017Z, _value: 19.0},
{_time: 2020-09-23T15:48:02.017Z, _value: 16.0},
{_time: 2021-09-23T15:38:02.017Z, _value: 20.0},
{_time: 2021-09-23T15:28:02.017Z, _value: 20.0},
{_time: 2021-09-23T15:18:02.017Z, _value: 22.0},
{_time: 2021-09-23T15:08:02.017Z, _value: 7.0},
{_time: 2021-09-23T14:58:02.017Z, _value: 20.0},
{_time: 2021-09-23T14:48:02.017Z, _value: 19.0},
{_time: 2021-09-23T14:38:02.017Z, _value: 15.0},
{_time: 2021-09-23T14:28:02.017Z, _value: 19.0},
])
// |> yield(name: "data")
dueDate = 2021-09-23T14:28:02.017Z
data 
|> map(fn: (r) => ({ r with late: if r._time < dueDate then "true" else "false" }))
|> yield(name:"ontime")

In this instance i take my array of values data and then I map a new column based upon the conditional function you defined. Note that now that I have modifed by table its appropriate to yield() that data as my result. Here is the result in vscode.

@MPH1984,
I’ve also made a feature request. Feel free to comment:

1 Like

It would make development and testing much quicker, thanks for raising the FR.

Mike