Skip to content

creating/updating task with leading import statement not working #351

@tost11

Description

@tost11

Steps to reproduce:

Create a task with leading import statement

client.getTasksApi().createTaskCron("whatever",fluxQuery,"10 0 * * * *","01feb3ff2a370ff0");

fluxQuery like so:

import "experimental"

from(bucket: "user-1")
    |> range(start: experimental.addDuration(d: -1d, to: today()), stop: today())
    |> filter(fn: (r) => r["system"] == "2")
    |> filter(fn: (r) => r["_field"] == "ChargeWatt" or r["_field"] == "Duration")
    |> pivot(rowKey: ["_time"], columnKey: ["_field"], valueColumn: "_value")
    |> map(fn: (r) => ({r with _value: r.ChargeWatt * r.Duration / 1000.0 / 60.0}))
    |> cumulativeSum()
    |> max()
    |> map(fn: (r) => ({r with _time: today(), _measurement: "day-values", _field: "outcome"}))

It seems the flux query is generated wrong.

String fluxWithOptions = String.format("option task = {name: \"%s\", %s} \n %s", name, repetition, flux);

The additional options seems to be added before the import statement:

option task = {name: "whatever", cron: "12 0 * * * *"}

import "experimental"

from(bucket: "user-1")
    |> ...

It should be:

import "experimental"

option task = {name: "whatever", cron: "12 0 * * * *"}

from(bucket: "user-1")
    |> ...

also the updateTask functions are not working

also could it be that on TaskCreateRequest the name attribute is missing some creation functions didn't work because of that

Expected behavior:
Create a new Task.

Actual behavior:
Error from influx because import statement is not allowed at this position
"invalid options: loc 2:2-2:8: invalid statement @2:2-2:8: import"

Specifications:

  • Client Version: 5.0.0
  • InfluxDB Version: 2.2
  • JDK Version: java-1.11.0-openjdk-amd64
  • Platform: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions