Closed zcattacz closed 2 months ago
@zcattacz In what context are you running this function? Is it in a task, or just a one-off query?
Hi thanks for replying. I use it in the following script. Which is run in query for debugging and then in task for the job. I intent to reporting for the issue in Task.
import "sql"
import "strings"
import "experimental/array"
import "join"
import "date"
import "influxdata/influxdb/tasks"
import "types"
// without this the webUI for Task wouldn't let me save,
// "Invalid flux script. Please check your query text."
// though with this the webUI sometimes underlines "task",
// hinting "Avoid using `task` as an identifier name ... it may be provided at runtime.
// I checked task name is identical.
// not sure if this is related or what is the right way to handle this
option task = {name: "cq_mstat_5m", every: 5m, offset: 30s}
cnlTbl =
sql.from(
driverName: "postgres",
dataSourceName: "postgresql://...",
query:"...",
)
arrCnls =
cnlTbl
|> tableFind(fn: (key) => true)
|> getColumn(column: "cnl_num")
_tDstEnd =
from(bucket: "cache_mach_stat_5m")
|> range(start: time(v: "2020-01-01T00:00:00.00Z"))
|> max(column: "_time")
|> last(column: "_time")
|> tableFind(fn: (key) => true)
|> getColumn(column: "_time")
tDstEnd = _tDstEnd[0]
//_tPrevTaskSucc =
// from(bucket: "cq_task_param")
// |> range(start: time(v: "2020-01-01T00:00:00Z"))
// |> filter(fn: (r) => r._measurement == "cq_mstat_5m" and r._field == "lastSucc")
// |> sort(columns: ["_time"], desc: true)
// |> first()
// |> tableFind(fn: (key) => true)
// |> getColumn(column: "_time")
//It was,
tPrevTaskSucc = tasks.lastSuccess(orTime: tDstEnd)
//tPrevTaskSucc = _tPrevTaskSucc[0]
tDstEnd1 =
if tDstEnd < tPrevTaskSucc then
date.add(d: 7d, to: tDstEnd)
else
date.add(d: task.every, to: tPrevTaskSucc)
array.from(
rows: [
{"_time": now(), "_field": "tPrevTaskSucc", "_value": tPrevTaskSucc},
//{"_time": now(), "_field": "tDstEnd", "_value": tDstEnd},
//{"_time": now(), "_field": "tSrcEnd", "_value": tSrcEnd[0]},
],
)
|> set(key: "_measurement", value: "rplc_cq")
|> to(bucket: "rplc1_cq_param")
//...
I add this as task then manually repeatedly executed for a few times, the WebUI always report success, later when I check the rplc1_cq_param
bucket, tPrevTaskSucc
is always the same value.
This issue has had no recent activity and will be closed soon.
3430 still stands in InfluxDB v2.7.7 (git: e9e0f744fa) build_date: 2024-07-11T18:45:02Z
Always return orTime.