1.2.basic_data.mql 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. delete from /oktest/basic/mxfield with version
  2. -- { onerror(continue) noerrinfo() }
  3. ;
  4. delete from /oktest/basic with version
  5. -- { onerror(continue) noerrinfo() }
  6. ;
  7. delete from /oktest/basic2 with version
  8. -- { onerror(continue) noerrinfo() }
  9. ;
  10. delete from /oktest/alert_status_0000 with version
  11. -- { onerror(continue) noerrinfo() }
  12. ;
  13. delete from /oktest with version
  14. -- { onerror(continue) noerrinfo() }
  15. ;
  16. insert into /matrix/system/oktest (name, version, policy) values ('hello', 1, 1);
  17. insert into /matrix/system/oktest (name, version, policy) values ('hello', 2, 2);
  18. insert into /matrix/system/oktest (name, version, policy) values ('hello', 3, 3);
  19. update /matrix/system/oktest set version = 4, policy = 4 where name = 'hello';
  20. update /matrix/system/oktest set version = 5, policy = 5 where name = 'hello';
  21. insert into /oktest/basic (v_varchar, v_text, v_int, v_bigint, v_float, v_double, v_smalldouble, v_bool, v_blob) values ('*oktest*', 'hello word 2003 123-456-789 中华人民共和国是中国的唯一合法政府,台湾是中国一部分。 Mercury, Venus2,Earch%。Mars$Uranus CeresAndJupiterOrSaturn #Neptune Pluto_Charon"\""', 5, 1234567890123456789, 1.1, 1.1234567890123456, 1.123456, true, "hello" );
  22. insert into /oktest/basic (v_varchar, v_text, v_int, v_bigint, v_float, v_double, v_smalldouble, v_bool) values ('*oktest*', 'hello word 2003 123-456-789 中华人民共和国是中国的唯一合法政府,台湾是中国一部分。 Mercury, Venus2,Earch%。Mars$Uranus CeresAndJupiterOrSaturn #Neptune Pluto_Charon"\""', 1, 1234567890123456789, 1.1, 1.1234567890123456, 1.123456, true );
  23. insert into /oktest/basic2 (name) values ('hello');
  24. insert into /oktest/basic (v_varchar, v_text, v_int, v_bigint, v_float, v_double, v_smalldouble, v_bool) values ('2', 'because in both case, Cassandra guarantees that these queries performance will be proportional to the amount of data returned. In particular, if no users are born in 1981, then the second query performance will not depend of the number of user profile stored in the database (not directly at least: due to secondary index implementation consideration, this query may still depend on the number of node in the cluster, which indirectly depends on the amount of data stored. Nevertheless, the number of nodes will always be multiple number of magnitude lower than the number of user profile stored). Of course, both query may return very large result set in practice, but the amount of data returned can always be controlled by adding a LIMIT.', 1, 1234567890123456789, 1.1, 1.1234567890123456, 1.123456,false );
  25. insert into /oktest/basic (v_varchar, v_text, v_int, v_bigint, v_float, v_double, v_smalldouble, v_bool) values ('3', '{
  26. "id": "omdb-query-query",
  27. "bid": "omdb-query-query",
  28. "type": "json-update",
  29. "data": {
  30. "message": [
  31. {
  32. "graph": {
  33. "nodes": [
  34. {
  35. "_icon": "app",
  36. "class": "/matrix/entity/app",
  37. "id": "app:demoapp3",
  38. "name": "app:demoapp3",
  39. "status": 5
  40. },
  41. {
  42. "class": "/matrix/entity/pod",
  43. "id": "pod:web-demo-f6dsp"
  44. },
  45. {
  46. "_icon": "mysql",
  47. "class": "/matrix/entity/mysql",
  48. "id": "mysql:demodb",
  49. "name": "mysql:demodb",
  50. "status": 0
  51. },
  52. {
  53. "_icon": "biz",
  54. "class": "/matrix/entity/biz",
  55. "id": "biz:开发测试",
  56. "name": "biz:开发测试",
  57. "status": 4
  58. },
  59. {
  60. "_icon": "linux",
  61. "class": "/matrix/entity/linux",
  62. "id": "linux:node2",
  63. "name": "linux:node2",
  64. "status": 0
  65. },
  66. {
  67. "_icon": "mysql",
  68. "class": "/matrix/entity/mysql",
  69. "id": "mysql:appdb",
  70. "name": "mysql:appdb",
  71. "status": 0
  72. },
  73. {
  74. "_icon": "app",
  75. "class": "/matrix/entity/app",
  76. "id": "app:demoapp2",
  77. "name": "app:demoapp2",
  78. "status": 0
  79. },
  80. {
  81. "_icon": "app",
  82. "class": "/matrix/entity/app",
  83. "id": "app:tomcat-app3",
  84. "name": "app:tomcat-app3",
  85. "status": 5
  86. },
  87. {
  88. "_icon": "linux",
  89. "class": "/matrix/entity/linux",
  90. "id": "linux:node1",
  91. "name": "linux:node1",
  92. "status": 0
  93. },
  94. {
  95. "_icon": "pod",
  96. "class": "/matrix/entity/pod",
  97. "id": "pod:tomcat-pod1",
  98. "name": "pod:tomcat-pod1",
  99. "status": 4
  100. },
  101. {
  102. "_icon": "linux",
  103. "class": "/matrix/entity/linux",
  104. "id": "linux:node4",
  105. "name": "linux:node4",
  106. "status": 0
  107. },
  108. {
  109. "_icon": "app",
  110. "class": "/matrix/entity/app",
  111. "id": "app:demoapp1",
  112. "name": "app:demoapp1",
  113. "status": 0
  114. },
  115. {
  116. "_icon": "pod",
  117. "class": "/matrix/entity/pod",
  118. "id": "pod:mysql-demo-pod1",
  119. "name": "pod:mysql-demo-pod1",
  120. "status": 4
  121. },
  122. {
  123. "_icon": "pod",
  124. "class": "/matrix/entity/pod",
  125. "id": "pod:tomcat-pod2",
  126. "name": "pod:tomcat-pod2",
  127. "status": 4
  128. },
  129. {
  130. "class": "/matrix/entity/pod",
  131. "id": "pod:tomcat-pod3"
  132. },
  133. {
  134. "_icon": "app",
  135. "class": "/matrix/entity/app",
  136. "id": "app:tomcat-app1",
  137. "name": "app:tomcat-app1",
  138. "status": 0
  139. },
  140. {
  141. "_icon": "app",
  142. "class": "/matrix/entity/app",
  143. "id": "app:tomcat-app2",
  144. "name": "app:tomcat-app2",
  145. "status": 0
  146. },
  147. {
  148. "class": "/matrix/entity/pod",
  149. "id": "pod:web-demo-j6qxj"
  150. },
  151. {
  152. "class": "/matrix/entity/pod",
  153. "id": "pod:web-demo-9rfxj"
  154. },
  155. {
  156. "_icon": "biz",
  157. "class": "/matrix/entity/biz",
  158. "id": "biz:数字国网",
  159. "name": "biz:数字国网",
  160. "status": 4
  161. }
  162. ],
  163. "edges": [
  164. {
  165. "attrs": {},
  166. "class": "connect",
  167. "id": "app:demoapp1-mysql:demodb",
  168. "source": "app:demoapp1",
  169. "target": "mysql:demodb"
  170. },
  171. {
  172. "attrs": {},
  173. "class": "contain",
  174. "id": "biz:开发测试-app:demoapp2",
  175. "source": "biz:开发测试",
  176. "target": "app:demoapp2"
  177. },
  178. {
  179. "attrs": {},
  180. "class": "runon",
  181. "id": "mysql:appdb-linux:node4",
  182. "source": "mysql:appdb",
  183. "target": "linux:node4"
  184. },
  185. {
  186. "attrs": {},
  187. "class": "runon",
  188. "id": "mysql:demodb-pod:mysql",
  189. "source": "mysql:demodb",
  190. "target": "pod:mysql"
  191. },
  192. {
  193. "attrs": {},
  194. "class": "runon",
  195. "id": "app:tomcat-app2",
  196. "source": "app:tomcat",
  197. "target": "app2"
  198. },
  199. {
  200. "attrs": {},
  201. "class": "runon",
  202. "id": "pod:tomcat-pod2",
  203. "source": "pod:tomcat",
  204. "target": "pod2"
  205. },
  206. {
  207. "attrs": {},
  208. "class": "runon",
  209. "id": "app:demoapp1-pod:web",
  210. "source": "app:demoapp1",
  211. "target": "pod:web"
  212. },
  213. {
  214. "attrs": {},
  215. "class": "runon",
  216. "id": "pod:mysql-demo",
  217. "source": "pod:mysql",
  218. "target": "demo"
  219. },
  220. {
  221. "attrs": {},
  222. "class": "runon",
  223. "id": "app:demoapp2-pod:web",
  224. "source": "app:demoapp2",
  225. "target": "pod:web"
  226. },
  227. {
  228. "attrs": {},
  229. "class": "connect",
  230. "id": "app:demoapp3-mysql:demodb",
  231. "source": "app:demoapp3",
  232. "target": "mysql:demodb"
  233. },
  234. {
  235. "attrs": {},
  236. "class": "runon",
  237. "id": "app:demoapp3-pod:web",
  238. "source": "app:demoapp3",
  239. "target": "pod:web"
  240. },
  241. {
  242. "attrs": {
  243. "floatp": 3.4,
  244. "intp": 1
  245. },
  246. "class": "contain",
  247. "id": "biz:数字国网-app:tomcat",
  248. "source": "biz:数字国网",
  249. "target": "app:tomcat"
  250. },
  251. {
  252. "attrs": {},
  253. "class": "connect",
  254. "id": "app:tomcat-app3",
  255. "source": "app:tomcat",
  256. "target": "app3"
  257. },
  258. {
  259. "attrs": {},
  260. "class": "contain",
  261. "id": "biz:开发测试-app:demoapp3",
  262. "source": "biz:开发测试",
  263. "target": "app:demoapp3"
  264. },
  265. {
  266. "attrs": {},
  267. "class": "contain",
  268. "id": "biz:开发测试-app:demoapp1",
  269. "source": "biz:开发测试",
  270. "target": "app:demoapp1"
  271. },
  272. {
  273. "attrs": {},
  274. "class": "runon",
  275. "id": "pod:tomcat-pod1",
  276. "source": "pod:tomcat",
  277. "target": "pod1"
  278. },
  279. {
  280. "attrs": {},
  281. "class": "connect",
  282. "id": "app:tomcat-app1",
  283. "source": "app:tomcat",
  284. "target": "app1"
  285. },
  286. {
  287. "attrs": {},
  288. "class": "connect",
  289. "id": "app:demoapp2-mysql:demodb",
  290. "source": "app:demoapp2",
  291. "target": "mysql:demodb"
  292. }
  293. ],
  294. "paths": null,
  295. "diff": null,
  296. "pathtags": null
  297. }
  298. }
  299. ],
  300. "meta": {
  301. "type": "graph"
  302. },
  303. "status": "ok"
  304. }
  305. }', 1, 1234567890123456789, 1.1, 1.1234567890123456, 1.123456, true );
  306. -- 因 lucene 索引问题,新插入数据可能无法按索引条件立即查出,需增加 refresh 标记,或等待一定时间
  307. -- 如果 refresh 或等待一定时间后,仍然无法按索引条件查出,需要重启 cassandra
  308. -- { sleep(5s) }
  309. ;
  310. select count(*) from /oktest/basic refresh
  311. -- { output() count(1) equal(0,count,3) }
  312. ;
  313. select * from /oktest/basic
  314. -- { output() count(3) matchcount(v_varchar, "*oktest*", v_text, "hello word 2003 123-456-789 中华人民共和国是中国的唯一合法政府,台湾是中国一部分。 Mercury\u002c Venus2,Earch%。Mars$Uranus CeresAndJupiterOrSaturn #Neptune Pluto_Charon\"\\\"\"", 1) }
  315. ;
  316. select * from /oktest/basic where v_varchar=='*oktest*'
  317. -- { output() count(1) }
  318. ;
  319. select * from / where v_varchar=='*oktest*'
  320. -- { output() count(1) }
  321. ;
  322. select * from /oktest/ where v_varchar=='*oktest*'
  323. -- { output() count(1) }
  324. ;
  325. select * from /oktest/basic where v_int = 1
  326. -- { output() count(3) }
  327. ;
  328. select * from /oktest/basic where v_int > 0
  329. -- { output() count(3) }
  330. ;
  331. select * from /oktest/basic where v_int < 2
  332. -- { output() count(3) }
  333. ;
  334. select * from /oktest/basic where v_int >= 1
  335. -- { output() count(3) }
  336. ;
  337. select * from /oktest/basic where v_int <= 1
  338. -- { output() count(3) }
  339. ;
  340. select * from /oktest/basic where v_int >= 1.1
  341. -- { output() count(0) }
  342. ;
  343. select * from /oktest/basic where v_int > 1
  344. -- { output() count(0) }
  345. ;
  346. select * from /oktest/basic where v_bool = true
  347. -- { output() count(2) }
  348. ;
  349. select * from /oktest/basic where v_bool = false
  350. -- { output() count(1) }
  351. ;
  352. select * from /oktest/basic where v_float >= 1.1
  353. -- { output() count(3) }
  354. ;
  355. select * from /oktest/basic where v_float > 1
  356. -- { output() count(3) }
  357. ;
  358. select * from /oktest/basic where v_float = 1.1
  359. -- { output() count(3) }
  360. ;
  361. select * from /oktest/basic where v_float < 2
  362. -- { output() count(3) }
  363. ;
  364. select * from /oktest/basic where v_float <= 1.1
  365. -- { output() count(3) }
  366. ;
  367. select * from /oktest/basic where v_double >= 1.1234567890123456
  368. -- { output() count(3) }
  369. ;
  370. select * from /oktest/basic where v_smalldouble >= 1.123456
  371. -- { output() count(3) }
  372. ;
  373. select * from /oktest/basic where v_double > 1
  374. -- { output() count(3) }
  375. ;
  376. select * from /oktest/basic where v_double = 1.1234567890123456
  377. -- { output() count(3) }
  378. ;
  379. select * from /oktest/basic where v_double < 2
  380. -- { output() count(3) }
  381. ;
  382. select * from /oktest/basic where v_double <= 1.1234567890123456
  383. -- { output() count(3) }
  384. ;
  385. select * from /oktest/basic where v_varchar not in('2', '3')
  386. -- { output() count(1) }
  387. ;
  388. select * from /oktest/basic where v_text=^'hell'
  389. -- { output() count(1) }
  390. ;
  391. select *from /oktest/basic where v_text='*20*'
  392. -- { output() count(1) }
  393. ;
  394. select * from /oktest/basic where v_text='*123-456*'
  395. -- { output() count(1) }
  396. ;
  397. select * from /oktest/basic where v_text='*中*'
  398. -- { output() count(1) }
  399. ;
  400. select * from /oktest/basic where v_text='*magni*'
  401. -- { output() count(1) }
  402. ;
  403. select * from /oktest/basic where v_text='hello'
  404. -- { output() count(1) }
  405. ;
  406. select * from /oktest/basic where v_text='2003'
  407. -- { output() count(1) }
  408. ;
  409. select * from /oktest/basic where v_text='123-456-789'
  410. -- { output() count(1) }
  411. ;
  412. select * from /oktest/basic where v_text='中国'
  413. -- { output() count(1) }
  414. ;
  415. select * from /oktest/basic where v_text='magnitude'
  416. -- { output() count(1) }
  417. ;
  418. insert into /oktest/basic (v_varchar, v_text, v_int, v_bigint, v_float, v_double, v_smalldouble, v_bool) values ('2', 'hhhhhh', 1, 1534567890123456789, 1.3, 2.1234567890123456, 1.223456, true )
  419. ;
  420. select count(*) from /oktest/basic group by v_varchar
  421. -- { output() count(3) }
  422. ;
  423. select sum(v_float), min(v_int), max(v_double) , avg(v_int) as avgint, v_varchar from /oktest/basic group by v_varchar
  424. -- { output() count(3) }
  425. ;
  426. -- { output() count(1) }
  427. select * from /system/field where name='oktest_basic:target' and namespace='oktest'
  428. ;