1094.subquery.aggr.mql 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. SELECT id,prom.time('2025-01-01 09:09:09.090', '2025-01-03 19:19:19.191').find(name='test1').unit('sum','1d') FROM /test/bucketpromdb where id='bucketpromdb:wecisen1'
  2. -- 测试数据保留 7 天,在类定义中 bucket.ttl=7
  3. /**
  4. output()
  5. matchcount(id, "bucketpromdb:wecisen1", "prom.1.2", 2880, 1)
  6. **/
  7. ;
  8. select count(id),prom.count() from (
  9. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00').find(name='test1').unit('sum','1d') FROM /test/bucketpromdb
  10. ) group by prom
  11. /**
  12. timeout(60m)
  13. output()
  14. match(count, 3, "prom.0.2", 0)
  15. match(count, 1, "prom.0.2", 8)
  16. **/
  17. ;
  18. select count(id),prom from (
  19. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00').find(name='test1').unit('sum','1d') FROM /test/bucketpromdb
  20. ) group by prom
  21. /**
  22. timeout(60m)
  23. output()
  24. todomatch(count, 3, prom, null)
  25. match(count, 3)
  26. match(count, 1, "prom.0.2", 2880, "prom.7.2", 2880)
  27. **/
  28. ;
  29. select count(id),prom.avg().max().sum().count().min() from (
  30. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00').find(name='test1').unit('sum','1d') FROM /test/bucketpromdb
  31. ) group by prom
  32. /**
  33. timeout(60m)
  34. output()
  35. match(count, 3, prom, null)
  36. match(count, 1, "prom.0.2", 2880, "prom.0.8", 23040, "prom.0.11", 8)
  37. **/
  38. ;
  39. select count(*),count(prom) as promcount,prom.time('2025-01-03 00:00:00', '2025-01-08 00:00:00').find(name='test1').unit('sum','1d')
  40. FROM (
  41. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00') FROM /test/bucketpromdb
  42. )
  43. group by prom
  44. /**
  45. timeout(60m)
  46. output()
  47. match(count,1,promcount,1,"prom.len",5)
  48. match(count,3,promcount,3,"prom.len",0)
  49. **/
  50. ;
  51. select a.id, a.prom
  52. from
  53. (
  54. select * from /test/bucketpromdb
  55. ) a
  56. where a.id='bucketpromdb:wecisen1'
  57. /**
  58. timeout(60m)
  59. output()
  60. count(1)
  61. match("a.id","bucketpromdb:wecisen1","a.prom.len",1,"a.prom.0.2",1)
  62. **/
  63. ;
  64. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00').avg().groupby('name')
  65. FROM /test/bucketpromdb
  66. WHERE prom.time('2025-01-03 00:00:00', '2025-01-08 00:00:00').avg().groupby('name').assert(avg=1)
  67. /**
  68. timeout(60m)
  69. output()
  70. match("prom.0.0","test1","prom.0.3",1)
  71. **/
  72. ;
  73. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00').avg().groupby('name')
  74. FROM /test/bucketpromdb
  75. WHERE prom.time('2025-01-03 00:00:00', '2025-01-08 00:00:00').avg().groupby('name').assert($1=1)
  76. /**
  77. timeout(60m)
  78. output()
  79. match("prom.0.0","test1","prom.0.3",1)
  80. **/
  81. ;
  82. select id,prom.avg().groupby(name) from(
  83. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00')
  84. FROM /test/bucketpromdb
  85. WHERE prom.time('2025-01-03 00:00:00', '2025-01-08 00:00:00').avg().groupby(name).assert($1=1)
  86. )
  87. /**
  88. timeout(60m)
  89. output()
  90. match("prom.0.0","test1","prom.0.3",1)
  91. **/
  92. ;