1094.subquery.aggr.mql 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 x.id,x.prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00').find(name='test1').unit('sum','1d') from (
  30. SELECT id,prom FROM /test/bucketpromdb
  31. where id='bucketpromdb:wecisen1'
  32. ) x
  33. /**
  34. timeout(60m)
  35. output()
  36. match("x.prom.0.2", 2880, "x.prom.7.2", 2880)
  37. **/
  38. ;
  39. select count(id),prom.avg().max().sum().count().min() from (
  40. 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
  41. ) group by prom
  42. /**
  43. timeout(60m)
  44. output()
  45. match(count, 3, prom, null)
  46. match(count, 1, "prom.0.2", 2880, "prom.0.8", 23040, "prom.0.11", 8)
  47. **/
  48. ;
  49. 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')
  50. FROM (
  51. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00') FROM /test/bucketpromdb
  52. )
  53. group by prom
  54. /**
  55. timeout(60m)
  56. output()
  57. match(count,1,promcount,1,"prom.len",5)
  58. match(count,3,promcount,3,"prom.len",0)
  59. **/
  60. ;
  61. select a.id, a.prom
  62. from
  63. (
  64. select * from /test/bucketpromdb
  65. ) a
  66. where a.id='bucketpromdb:wecisen1'
  67. /**
  68. timeout(60m)
  69. output()
  70. count(1)
  71. match("a.id","bucketpromdb:wecisen1","a.prom.len",1,"a.prom.0.2",1)
  72. **/
  73. ;
  74. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00').avg().groupby('name')
  75. FROM /test/bucketpromdb
  76. WHERE prom.time('2025-01-03 00:00:00', '2025-01-08 00:00:00').avg().groupby('name').assert(avg=1)
  77. /**
  78. timeout(60m)
  79. output()
  80. match("prom.0.0","test1","prom.0.3",1)
  81. **/
  82. ;
  83. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00').avg().groupby('name')
  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. timeout(60m)
  88. output()
  89. match("prom.0.0","test1","prom.0.3",1)
  90. **/
  91. ;
  92. select id,prom.avg().groupby(name) from(
  93. SELECT id,prom.time('2025-01-02 00:00:00', '2025-01-10 00:00:00')
  94. FROM /test/bucketpromdb
  95. WHERE prom.time('2025-01-03 00:00:00', '2025-01-08 00:00:00').avg().groupby(name).assert($1=1)
  96. )
  97. /**
  98. timeout(60m)
  99. output()
  100. match("prom.0.0","test1","prom.0.3",1)
  101. **/
  102. ;