首页 > 其他分享 >Flux Union语法

Flux Union语法

时间:2022-08-25 14:55:37浏览次数:30  
标签:02 Union ThdA PM5350P 语法 Flux tag 2022 id

  • drop 、set、rename应该放最语句后端
  • join 只能连接两个表
  • union 可以并多个表
  • pivot 可以做行专列
  • filter用or比contains 快N倍
  • range显示起止时间可以加快查询速度
t_max = from(bucket: "po")
    |> range(start: 2022-02-01T00:00:00Z, stop: 2022-03-01T00:00:00Z)
    |> filter(fn: (r) => r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsA" or r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsB" or r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsC")
    |> set(key: "tag", value: "max")
    |> group(columns: ["tag_id_2022-02"])
    |> window(every: 1mo)
    |> max()
    //|> rename(columns: { _value: "max"})
    |> drop(columns: ["_time", "_start","_stop","_field","_measurement","table"])
t_min = from(bucket: "po")
    |> range(start: 2022-02-01T00:00:00Z, stop: 2022-03-01T00:00:00Z)
    |> filter(fn: (r) => r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsA" or r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsB" or r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsC")
    |> set(key: "tag", value: "min")
    |> group(columns: ["tag_id_2022-02"])
    |> window(every: 1mo)
    |> min()
    //|> rename(columns: { _value: "min"})
    |> drop(columns: ["_time", "_start","_stop","_field","_measurement","table"])

t_mean = from(bucket: "po")
    |> range(start: 2022-02-01T00:00:00Z, stop: 2022-03-01T00:00:00Z)
    |> filter(fn: (r) => r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsA" or r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsB" or r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsC")
    //|> filter(fn: (r) =>contains(value:  r["tag_id_2022-01"], set: ["c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsA"]))
    
    |> group(columns: ["tag_id_2022-02"])
    |> window(every: 1mo)
    |> mean()
    |> drop(columns: [ "_start","_stop","_field","_measurement"])
    |> set(key: "tag", value: "mean")

t_last = from(bucket: "po")
    |> range(start: 2022-02-01T00:00:00Z, stop: 2022-03-01T00:00:00Z)
    |> filter(fn: (r) => r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsA" or r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsB" or r["tag_id_2022-02"] == "c1.H_1AH1_PM5350P_1\\MHAI1\\ThdA\\phsC")
    |> set(key: "tag", value: "last")
    |> group(columns: ["tag_id_2022-02"])
    |> window(every: 1mo)
    |> last()
    |> drop(columns: ["_time", "_start","_stop","_field","_measurement","table"])

union(tables: [t_max,t_min,t_last,t_mean])
    |>pivot(rowKey: ["tag_id_2022-02"], columnKey: ["tag"], valueColumn: "_value")

标签:02,Union,ThdA,PM5350P,语法,Flux,tag,2022,id
From: https://www.cnblogs.com/wuhailong/p/16624268.html

相关文章

  • C#中=>语法
    一、Fromto:  https://blog.csdn.net/qq_41598072/article/details/124017274=>是Lambda表达式参数=>关于参数的函数举例:Func<int,int>Add=(x,y)=>x+y;......
  • 语法错误 : 缺少“;”(在“类型”的前面)
    今天用老版的vs写C写到怀疑人生。。。一个简单的for循环就报n个错误。。。我愣是看了一行简单的代码看了好久,看到怀疑我不会写代码。。。后来bing了一下才发现,原来老版......
  • 2. json语法规则
    1.前言JSON的语法与JavaScript中的对象很像,在JSON中主要使用以下两种方式来表示数据:Object(对象):键/值对(名称/值)的集合,使用花括号{}定义。在每个键/值对中,以键开头......
  • 盒子模型、 浮动布局、定位属性、 z-index、JavaScript基础语法
    今日内容概要盒子模型浮动布局定位属性z-indexJavaScript基础语法今日内容详细盒子模型所有的标签都可以看成是一个快递盒1.外边距(margin):指标签之间的距离(......
  • C# InfluxDB批量插入
    Samplesfor(intj=0;j<96;j++)//24*60/15{vardt=_endDateTime.AddMinutes(-j*15).AddMilliseconds(ran.Next(1000));varts=......
  • setup语法糖
    <template><div>AppContent:{{message}}</div><button@click="changeMessage">修改message</button><showInfoname="why":age="18"......
  • nginx配置文件语法高亮
    下载nginx.vim支持文件[root@uat-sh-bs-3-b5-nginx-0-11vim74]#cd/usr/share/vim/vim74/syntax/[root@uat-sh-bs-3-b5-nginx-0-11vim74]#wget--no-check-certif......
  • python语法随笔:{!r}、*a, = 、enumerate、dic[1]和dic[1.0]、dis、isinstance(True,in
    f"{!r}"等价与'{!r}'.format()输出会带上引号和print('%r'%a)相同a='2'print(f"{a}")print("{}".format(a))print(f"{a!r}")print("{!r}".format(a))输......
  • Markdown基础语法
    Markdown学习标题三级标题字体Hello,World粗体Hello,World斜体Hello,World斜体加粗Hello,World删除线引用右尖括号+空格分割线三个小横杠“-”+回车三......
  • Java基本语法
    >JAVA基本语法标识符定义:凡是自己可以起名字的地方都叫标识符。涉及到的结构:包名、类名、接口名、方法名、变量名、常量名。标识符命名规则:(必须遵守,否则编译不通过)1.......