Flux查询: 如果我不限制使用的流,则join.inner()不返回任何内容。

huangapple go评论44阅读模式
英文:

Flux Query : join.inner() returns nothing if I don't limit my stream used

问题

我对如何使用join.inner()函数有一些困惑。似乎只有在我对要使用join.inner函数的流使用limit()函数时,我才能获得一个正确的结果。

如果不对左侧的流进行限制,我不会收到任何错误,但也不会获得任何结果。这是因为我如何获取左侧的流吗?您有关于我在这里做错了什么的想法吗?

我对使用InfluxDB和Flux语言都很新,所以可能是我的问题。

感谢大家的回答!

import "array"
import "join"

left =
    from(bucket: "TestBucket")
    |> range(start: 0)
    |> filter(fn: (r) => r["_measurement"] == "TestMeasurement")
    |> limit(n: 1000000000000000000)
    |> group()
    //|> yield(name: "LEFT")

right =
    array.from(
        rows: [
            {arrayValue: "123", _time: 2023-02-07T12:00:00.000Z}, //此时间戳存在于左侧流中
        ],
    )
    //|> yield(name: "RIGHT")

result = join.inner(
    left: left,
    right: right,
    on: (l, r) => l._time == r._time, //我确保有一个共同的时间
    as: (l, r) => ({l with rightValue: r.arrayValue}),
)
|> yield(name: "RESULT")
英文:

I get an issue understanding how to use the join.inner() function.
It seems I can only have a result (and the correct one) if I use the limit() function to the stream I want to use the join.inner function with.

If don't limit this left stream, I don't get any error but just no result.
It is because of how I get my left stream ?
Do you have any idea what I am doing wrong here ?

I am pretty new using InfluxDB therefore the flux language so it must be me.

Thank you all for your answers !

import "array"
import "join"

left =
    from(bucket: "TestBucket")
    |> range(start: 0)
    |> filter(fn: (r) => r["_measurement"] == "TestMeasurement")
    |> limit(n : 1000000000000000000)
    |> group()
     //|> yield(name: "LEFT")
    

right =
    array.from(
        rows: [
            {arrayValue: "123", _time: 2023-02-07T12:00:00.000Z}, //This timestamp exists in the left stream
        ],
    )
    //|> yield(name: "RIGHT")

result = join.inner(
    left: left,
    right: right,
    on: (l, r) => l._time == r._time, // I made sure that there is indeed a common time 
    as: (l, r) => ({l with rightValue: r.arrayValue}),
)
    |> yield(name: "RESULT") 

答案1

得分: 1

Ok, 解决方案是根据“_time”列对流和表进行分组:
|> group(columns: ["_time"])

英文:

Ok, the solution was to group by _time column the stream AND the table :
|> group(columns: ["_time"])

huangapple
  • 本文由 发表于 2023年2月8日 17:00:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75383360.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定