-
Notifications
You must be signed in to change notification settings - Fork 1
/
queries.json
3040 lines (3038 loc) · 137 KB
/
queries.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"queries": [
{
"id": "12EBW5JKMBVOKUUANQPR1M",
"name": "Disk space usage",
"group": "amazon_reviews",
"comment": "",
"query": "SELECT\n disk_name,\n formatReadableSize(sum(data_compressed_bytes) AS size) AS compressed,\n formatReadableSize(sum(data_uncompressed_bytes) AS usize) AS uncompressed,\n round(usize / size, 2) AS compr_rate,\n sum(rows) AS rows,\n count() AS part_count\nFROM system.parts\nWHERE (active = 1) AND (table = 'amazon_reviews')\nGROUP BY disk_name\nORDER BY size DESC;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "BWOLVGMCMNCC3JDWF8EQGB",
"name": "Top 10 most-helpful reviews",
"group": "amazon_reviews",
"comment": "",
"query": "SELECT\n product_title,\n review_headline\nFROM amazon.amazon_reviews\nORDER BY helpful_votes DESC\nLIMIT 10;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "2DSBPSYXKLHRWNWMDPSUJN",
"name": "Top 10 products with most reviews",
"group": "amazon_reviews",
"comment": "",
"query": "SELECT\n any(product_title),\n count()\nFROM amazon.amazon_reviews\nGROUP BY product_id\nORDER BY 2 DESC\nLIMIT 10;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "OJJIEGD4NZK6KWH8FHYD64",
"name": "Avg review ratings per month per product",
"group": "amazon_reviews",
"comment": "",
"query": "SELECT\n toStartOfMonth(review_date) AS month,\n any(product_title),\n avg(star_rating) AS avg_stars\nFROM amazon.amazon_reviews\nGROUP BY\n month,\n product_id\nORDER BY\n month DESC,\n product_id ASC\nLIMIT 20;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "C8VZQAGWJKHVQFFTRB2R7B",
"name": "Total number of votes per product category",
"group": "amazon_reviews",
"comment": "",
"query": "SELECT\n sum(total_votes),\n product_category\nFROM amazon.amazon_reviews\nGROUP BY product_category\nORDER BY 1 DESC\n",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "AT61M2PNSTBFNVKESBTJWE",
"name": "Find products with 'awful' in reviews",
"group": "amazon_reviews",
"comment": "",
"query": "SELECT\n product_id,\n any(product_title),\n avg(star_rating),\n count() AS count\nFROM amazon.amazon_reviews\nWHERE position(review_body, 'awful') > 0\nGROUP BY product_id\nORDER BY count DESC\nLIMIT 50;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "VWSFKKJTECSIDPHNCYE5BP",
"name": "Find products with 'awesome' in reviews",
"group": "amazon_reviews",
"comment": "",
"query": "SELECT\n product_id,\n any(product_title),\n avg(star_rating),\n count() AS count\nFROM amazon.amazon_reviews\nWHERE position(review_body, 'awesome') > 0\nGROUP BY product_id\nORDER BY count DESC\nLIMIT 50;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "GEOICKHUJBUXMYROUXJK7C",
"name": "CPU/network utilization per web server",
"group": "mgbench",
"comment": "",
"query": "-- Q1.1: What is the CPU/network utilization for each web server since midnight?\n\nSELECT machine_name,\n MIN(cpu) AS cpu_min,\n MAX(cpu) AS cpu_max,\n AVG(cpu) AS cpu_avg,\n MIN(net_in) AS net_in_min,\n MAX(net_in) AS net_in_max,\n AVG(net_in) AS net_in_avg,\n MIN(net_out) AS net_out_min,\n MAX(net_out) AS net_out_max,\n AVG(net_out) AS net_out_avg\nFROM (\n SELECT machine_name,\n COALESCE(cpu_user, 0.0) AS cpu,\n COALESCE(bytes_in, 0.0) AS net_in,\n COALESCE(bytes_out, 0.0) AS net_out\n FROM mgbench.logs1\n WHERE machine_name IN ('anansi','aragog','urd')\n AND log_time >= TIMESTAMP '2017-01-11 00:00:00'\n) AS r\nGROUP BY machine_name;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "FKYNODO5J9SFHP9K7VXJAZ",
"name": "Machine offline in the past day",
"group": "mgbench",
"comment": "",
"query": "-- Q1.2: Which computer lab machines have been offline in the past day?\n\nSELECT machine_name,\n log_time\nFROM mgbench.logs1\nWHERE (machine_name LIKE 'cslab%' OR\n machine_name LIKE 'mslab%')\n AND load_one IS NULL\n AND log_time >= TIMESTAMP '2017-01-10 00:00:00'\nORDER BY machine_name,\n log_time;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "EVVZPZ2K5VDLHJ69SNJH1L",
"name": "Hourly average metrics for specific workstation last 10 days",
"group": "mgbench",
"comment": "",
"query": "-- Q1.3: What are the hourly average metrics during the past 10 days for a specific workstation?\n\nSELECT dt,\n hr,\n AVG(load_fifteen) AS load_fifteen_avg,\n AVG(load_five) AS load_five_avg,\n AVG(load_one) AS load_one_avg,\n AVG(mem_free) AS mem_free_avg,\n AVG(swap_free) AS swap_free_avg\nFROM (\n SELECT CAST(log_time AS DATE) AS dt,\n EXTRACT(HOUR FROM log_time) AS hr,\n load_fifteen,\n load_five,\n load_one,\n mem_free,\n swap_free\n FROM mgbench.logs1\n WHERE machine_name = 'babbage'\n AND load_fifteen IS NOT NULL\n AND load_five IS NOT NULL\n AND load_one IS NOT NULL\n AND mem_free IS NOT NULL\n AND swap_free IS NOT NULL\n AND log_time >= TIMESTAMP '2017-01-01 00:00:00'\n) AS r\nGROUP BY dt,\n hr\nORDER BY dt,\n hr;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "JMQOG4IV5ADD46Y6QBG4AO",
"name": "Server blocked on disk I/O",
"group": "mgbench",
"comment": "",
"query": "-- Q1.4: Over 1 month, how often was each server blocked on disk I/O?\n\nSELECT machine_name,\n COUNT(*) AS spikes\nFROM mgbench.logs1\nWHERE machine_group = 'Servers'\n AND cpu_wio > 0.99\n AND log_time >= TIMESTAMP '2016-12-01 00:00:00'\n AND log_time < TIMESTAMP '2017-01-01 00:00:00'\nGROUP BY machine_name\nORDER BY spikes DESC\nLIMIT 10;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "JJQ4TZJTB6HGD8YLEHPRCE",
"name": "Low memory external VMs",
"group": "mgbench",
"comment": "",
"query": "-- Q1.5: Which externally reachable VMs have run low on memory?\n\nSELECT machine_name,\n dt,\n MIN(mem_free) AS mem_free_min\nFROM (\n SELECT machine_name,\n CAST(log_time AS DATE) AS dt,\n mem_free\n FROM mgbench.logs1\n WHERE machine_group = 'DMZ'\n AND mem_free IS NOT NULL\n) AS r\nGROUP BY machine_name,\n dt\nHAVING MIN(mem_free) < 10000\nORDER BY machine_name,\n dt;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "POIZV5NWCQXZ7P7CYNQFYD",
"name": "Total hourly network traffic",
"group": "mgbench",
"comment": "",
"query": "-- Q1.6: What is the total hourly network traffic across all file servers?\n\nSELECT dt,\n hr,\n SUM(net_in) AS net_in_sum,\n SUM(net_out) AS net_out_sum,\n SUM(net_in) + SUM(net_out) AS both_sum\nFROM (\n SELECT CAST(log_time AS DATE) AS dt,\n EXTRACT(HOUR FROM log_time) AS hr,\n COALESCE(bytes_in, 0.0) / 1000000000.0 AS net_in,\n COALESCE(bytes_out, 0.0) / 1000000000.0 AS net_out\n FROM mgbench.logs1\n WHERE machine_name IN ('allsorts','andes','bigred','blackjack','bonbon',\n 'cadbury','chiclets','cotton','crows','dove','fireball','hearts','huey',\n 'lindt','milkduds','milkyway','mnm','necco','nerds','orbit','peeps',\n 'poprocks','razzles','runts','smarties','smuggler','spree','stride',\n 'tootsie','trident','wrigley','york')\n) AS r\nGROUP BY dt,\n hr\nORDER BY both_sum DESC\nLIMIT 10;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "W82SBNYFW4KENKMAJ1S9T1",
"name": "Requests cause server errors past 2 weeks",
"group": "mgbench",
"comment": "",
"query": "-- Q2.1: Which requests have caused server errors within the past 2 weeks?\n\nSELECT *\nFROM mgbench.logs2\nWHERE status_code >= 500\n AND log_time >= TIMESTAMP '2012-12-18 00:00:00'\nORDER BY log_time;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "T97TB1WVEF3V6WV1WTQSAX",
"name": "Detect user password file leak",
"group": "mgbench",
"comment": "",
"query": "-- Q2.2: During a specific 2-week period, was the user password file leaked?\n\nSELECT *\nFROM mgbench.logs2\nWHERE status_code >= 200\n AND status_code < 300\n AND request LIKE '%/etc/passwd%'\n AND log_time >= TIMESTAMP '2012-05-06 00:00:00'\n AND log_time < TIMESTAMP '2012-05-20 00:00:00';",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "F7QHSLYQGCGZDU1VFXKRMP",
"name": "Avg path depth for top-level requests in the past month",
"group": "mgbench",
"comment": "",
"query": "-- Q2.3: What was the average path depth for top-level requests in the past month?\n\nSELECT top_level,\n AVG(LENGTH(request) - LENGTH(REPLACE(request, '/', ''))) AS depth_avg\nFROM (\n SELECT SUBSTRING(request FROM 1 FOR len) AS top_level,\n request\n FROM (\n SELECT POSITION(SUBSTRING(request FROM 2), '/') AS len,\n request\n FROM mgbench.logs2\n WHERE status_code >= 200\n AND status_code < 300\n AND log_time >= TIMESTAMP '2012-12-01 00:00:00'\n ) AS r\n WHERE len > 0\n) AS s\nWHERE top_level IN ('/about','/courses','/degrees','/events',\n '/grad','/industry','/news','/people',\n '/publications','/research','/teaching','/ugrad')\nGROUP BY top_level\nORDER BY top_level;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "T25HUSKE3NRV5VFCNMVXAD",
"name": "Detect clients with excessive number of requests",
"group": "mgbench",
"comment": "",
"query": "-- Q2.4: During the last 3 months, which clients have made an excessive number of requests?\n\nSELECT client_ip,\n COUNT(*) AS num_requests\nFROM mgbench.logs2\nWHERE log_time >= TIMESTAMP '2012-10-01 00:00:00'\nGROUP BY client_ip\nHAVING COUNT(*) >= 100000\nORDER BY num_requests DESC;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "UTDAJTYXHW9CJSAIA1LXOU",
"name": "Daily unique visitors",
"group": "mgbench",
"comment": "",
"query": "-- Q2.5: What are the daily unique visitors?\n\nSELECT dt,\n COUNT(DISTINCT client_ip)\nFROM (\n SELECT CAST(log_time AS DATE) AS dt,\n client_ip\n FROM mgbench.logs2\n) AS r\nGROUP BY dt\nORDER BY dt;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "XUZAXVAMUELHY3JKXZJ57X",
"name": "Avg and max data transfer rates",
"group": "mgbench",
"comment": "",
"query": "-- Q2.6: What are the average and maximum data transfer rates (Gbps)?\n\nSELECT AVG(transfer) / 125000000.0 AS transfer_avg,\n MAX(transfer) / 125000000.0 AS transfer_max\nFROM (\n SELECT log_time,\n SUM(object_size) AS transfer\n FROM mgbench.logs2\n GROUP BY log_time\n) AS r;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "8NYJBXCD4FEHS1UMGQVI9G",
"name": "Detect freezing indoor temperature",
"group": "mgbench",
"comment": "",
"query": "-- Q3.1: Did the indoor temperature reach freezing over the weekend?\n\nSELECT *\nFROM mgbench.logs3\nWHERE event_type = 'temperature'\n AND event_value <= 32.0\n AND log_time >= '2019-11-29 17:00:00.000';",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "ARQ8M5MAJQAGWL2S5QKMVD",
"name": "Last 6 months number of door openings",
"group": "mgbench",
"comment": "",
"query": "-- Q3.4: Over the past 6 months, how frequently were each door opened?\n\nSELECT device_name,\n device_floor,\n COUNT(*) AS ct\nFROM mgbench.logs3\nWHERE event_type = 'door_open'\n AND log_time >= '2019-06-01 00:00:00.000'\nGROUP BY device_name,\n device_floor\nORDER BY ct DESC;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "WAMYYT2EUF2J9LEXVZ2HQW",
"name": "Find where temperature variations occur in winter and summer",
"group": "mgbench",
"comment": "",
"query": "\n\n-- Q3.5: Where in the building do large temperature variations occur in winter and summer?\n\nWITH temperature AS (\n SELECT dt,\n device_name,\n device_type,\n device_floor\n FROM (\n SELECT dt,\n hr,\n device_name,\n device_type,\n device_floor,\n AVG(event_value) AS temperature_hourly_avg\n FROM (\n SELECT CAST(log_time AS DATE) AS dt,\n EXTRACT(HOUR FROM log_time) AS hr,\n device_name,\n device_type,\n device_floor,\n event_value\n FROM mgbench.logs3\n WHERE event_type = 'temperature'\n ) AS r\n GROUP BY dt,\n hr,\n device_name,\n device_type,\n device_floor\n ) AS s\n GROUP BY dt,\n device_name,\n device_type,\n device_floor\n HAVING MAX(temperature_hourly_avg) - MIN(temperature_hourly_avg) >= 25.0\n)\nSELECT DISTINCT device_name,\n device_type,\n device_floor,\n 'WINTER'\nFROM temperature\nWHERE dt >= DATE '2018-12-01'\n AND dt < DATE '2019-03-01'\nUNION DISTINCT\nSELECT DISTINCT device_name,\n device_type,\n device_floor,\n 'SUMMER'\nFROM temperature\nWHERE dt >= DATE '2019-06-01'\n AND dt < DATE '2019-09-01';",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "VQWGJ3Y4A5CBGWXEQBDEJL",
"name": "Monthly power consumption metrics per device category",
"group": "mgbench",
"comment": "",
"query": "-- Q3.6: For each device category, what are the monthly power consumption metrics?\n\nSELECT yr,\n mo,\n SUM(coffee_hourly_avg) AS coffee_monthly_sum,\n AVG(coffee_hourly_avg) AS coffee_monthly_avg,\n SUM(printer_hourly_avg) AS printer_monthly_sum,\n AVG(printer_hourly_avg) AS printer_monthly_avg,\n SUM(projector_hourly_avg) AS projector_monthly_sum,\n AVG(projector_hourly_avg) AS projector_monthly_avg,\n SUM(vending_hourly_avg) AS vending_monthly_sum,\n AVG(vending_hourly_avg) AS vending_monthly_avg\nFROM (\n SELECT dt,\n yr,\n mo,\n hr,\n AVG(coffee) AS coffee_hourly_avg,\n AVG(printer) AS printer_hourly_avg,\n AVG(projector) AS projector_hourly_avg,\n AVG(vending) AS vending_hourly_avg\n FROM (\n SELECT CAST(log_time AS DATE) AS dt,\n EXTRACT(YEAR FROM log_time) AS yr,\n EXTRACT(MONTH FROM log_time) AS mo,\n EXTRACT(HOUR FROM log_time) AS hr,\n CASE WHEN device_name LIKE 'coffee%' THEN event_value END AS coffee,\n CASE WHEN device_name LIKE 'printer%' THEN event_value END AS printer,\n CASE WHEN device_name LIKE 'projector%' THEN event_value END AS projector,\n CASE WHEN device_name LIKE 'vending%' THEN event_value END AS vending\n FROM mgbench.logs3\n WHERE device_type = 'meter'\n ) AS r\n GROUP BY dt,\n yr,\n mo,\n hr\n) AS s\nGROUP BY yr,\n mo\nORDER BY yr,\n mo;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "UV8M4MAGS2PWAUOAYAAARM",
"name": "Cell towers by MCC",
"group": "geo",
"comment": "",
"query": "SELECT mcc, count() FROM geo.cell_towers GROUP BY mcc ORDER BY count() DESC LIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "VYCIREOC1QSOPKUVANIUZK",
"name": "Cell towers by type",
"group": "geo",
"comment": "",
"query": "SELECT radio, count() AS c FROM geo.cell_towers GROUP BY radio ORDER BY c DESC",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "2F9AQGB8CJR2DZ7ZAPY73Y",
"name": "Number of cell towers in Moscow",
"group": "geo",
"comment": "",
"query": "SELECT count() FROM geo.cell_towers\nWHERE pointInPolygon((lon, lat), (SELECT * FROM geo.moscow))",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "CMRQXM78SRPEZ9XU65GTQM",
"name": "Number of rows",
"group": "covid",
"comment": "",
"query": "SELECT formatReadableQuantity(count())\nFROM covid.covid19;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "356YYFGKQ2ED9OKIPNSRMC",
"name": "Number of cases confirmed",
"group": "covid",
"comment": "",
"query": "SELECT formatReadableQuantity(sum(new_confirmed))\nFROM covid.covid19;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "OBVBSACGRIAMJI16AI42VM",
"name": "Daily averages of new case",
"group": "covid",
"comment": "",
"query": "SELECT\n AVG(new_confirmed) OVER (PARTITION BY location_key ORDER BY date ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING) AS cases_smoothed,\n new_confirmed,\n location_key,\n date\nFROM covid.covid19;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "8KWGRUKIYUTKWVQW4CBYDP",
"name": "Lag new cases each day for US-DC",
"group": "covid",
"comment": "",
"query": "WITH latest_deaths_data AS\n ( SELECT location_key,\n date,\n new_deceased,\n new_confirmed,\n ROW_NUMBER() OVER (PARTITION BY location_key ORDER BY date DESC) as rn\n FROM covid.covid19)\nSELECT location_key,\n date,\n new_deceased,\n new_confirmed,\n rn\nFROM latest_deaths_data\nWHERE rn=1;",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "2MENTDSVJQML2VRCO2UTII",
"name": "Percentage new cases change per day",
"group": "covid",
"comment": "",
"query": "WITH confirmed_lag AS (\n SELECT\n *,\n lagInFrame(new_confirmed) OVER(\n PARTITION BY location_key\n ORDER BY date\n ) AS confirmed_previous_day\n FROM covid.covid19\n),\nconfirmed_percent_change AS (\n SELECT\n *,\n COALESCE(ROUND((new_confirmed - confirmed_previous_day) / confirmed_previous_day * 100), 0) AS percent_change\n FROM confirmed_lag\n)\nSELECT\n date,\n new_confirmed,\n percent_change,\n CASE\n WHEN percent_change > 0 THEN 'increase'\n WHEN percent_change = 0 THEN 'no change'\n ELSE 'decrease'\n END AS trend\nFROM confirmed_percent_change\nWHERE location_key = 'US_DC';",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "HQXNQZE26Z1QWYP9KC76ML",
"name": "Most common ingredients",
"group": "food",
"comment": "",
"query": "SELECT\n arrayJoin(NER) AS k,\n count() AS c\nFROM food.recipes\nGROUP BY k\nORDER BY c DESC\nLIMIT 50",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "1MXMHASDLEQIP4P1D1STND",
"name": "Usage per machine",
"group": "mgbench",
"comment": "",
"query": "SELECT machine_name,\n MIN(cpu) AS cpu_min,\n MAX(cpu) AS cpu_max,\n AVG(cpu) AS cpu_avg,\n MIN(net_in) AS net_in_min,\n MAX(net_in) AS net_in_max,\n AVG(net_in) AS net_in_avg,\n MIN(net_out) AS net_out_min,\n MAX(net_out) AS net_out_max,\n AVG(net_out) AS net_out_avg\nFROM (\n SELECT machine_name,\n COALESCE(cpu_user, 0.0) AS cpu,\n COALESCE(bytes_in, 0.0) AS net_in,\n COALESCE(bytes_out, 0.0) AS net_out\n FROM mgbench.logs1\n WHERE machine_name IN ('anansi','aragog','urd')\n AND log_time >= TIMESTAMP '2017-01-11 00:00:00'\n) AS r\nGROUP BY machine_name",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "478GCPU7LRTSZJBNY3EJT3",
"name": "License types per dependencies",
"group": "default",
"comment": "",
"query": "SELECT library_name, license_type, license_path FROM system.licenses ORDER BY library_name COLLATE 'en'",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "7YB4Q9HMD22ZV7VQWBFREA",
"name": "Number cumulative contributors",
"group": "git",
"comment": "",
"query": "WITH states AS\n (\n SELECT\n month,\n uniqState(actor_login) AS uniq_users\n FROM git.github_events\n WHERE (repo_name LIKE 'ClickHouse%') AND (event_type = 'PullRequestEvent')\n GROUP BY toStartOfMonth(created_at) AS month\n ORDER BY month ASC\n )\nSELECT\n month,\n uniqMerge(uniq_users) OVER (ORDER BY month ASC) AS cul_users\nFROM states",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "KIZPJXDYG1QB6DQDFSAVIE",
"name": "Number of unique and cumulative contributors",
"group": "git",
"comment": "",
"query": "SELECT\n month,\n arrayUniq(cul_users) AS cul_users,\n arrayUniq(uniq_users) AS uniq_users\nFROM\n(\n SELECT\n month,\n groupArrayDistinctArray(uniq_users) OVER (ORDER BY month ASC) AS cul_users,\n groupArrayDistinct(actor_login) AS uniq_users\n FROM git.github_events\n WHERE (repo_name LIKE 'ClickHouse%') AND (event_type = 'PullRequestEvent')\n GROUP BY toStartOfMonth(created_at) AS month\n ORDER BY month ASC\n)\n",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "DCQPNPAIMAQXRLHYURLKVJ",
"name": "Show tables",
"group": "git",
"comment": "",
"query": "SHOW TABLES IN git",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "9YHSK62D6WHC5ARCBOJEO7",
"name": "Show events from dbt-clickhouse repo",
"group": "git",
"comment": "",
"query": "SELECT * FROM git.github_events WHERE repo_name LIKE '%/dbt-clickhouse' ORDER BY created_at ASC",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "1IXC5PU4QCXSH5DHGQRU6F",
"name": "Show events from Clickhouse/dbt-clickhouse repo",
"group": "git",
"comment": "",
"query": "SELECT * FROM git.github_events WHERE repo_name LIKE 'ClickHouse/dbt-clickhouse' ORDER BY created_at ASC",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "JAUTYJJXBOSATPJD9B624X",
"name": "Select 1 event",
"group": "git",
"comment": "",
"query": "SELECT * FROM git.github_events LIMIT 1",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "1BSPOBWAT6PUOCYXYNPNML",
"name": "Compute if commit days are consecutive",
"group": "git",
"comment": "",
"query": "SELECT\n author,\n toDate(day) as day,\n any(day) OVER (PARTITION BY author ORDER BY day ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_commit,\n dateDiff('day', previous_commit, day) AS day_diff,\n if(day_diff = 1, 1, 0) AS consecutive\nFROM\n(\n SELECT author, toStartOfDay(time) AS day FROM git.clickhouse_commits GROUP BY author, day ORDER BY author ASC, day ASC\n)\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "WSHUEPJP9TNJUH7QITWWOR",
"name": "Average and median rewrite time across all files",
"group": "git",
"comment": "",
"query": "WITH\n changes AS\n (\n SELECT\n path,\n commit_hash,\n max_time,\n type,\n num_added,\n num_deleted,\n sum(num_added - num_deleted) OVER (PARTITION BY path ORDER BY max_time ASC) AS current_size,\n if(current_size > 0, num_added / current_size, 0) AS percent_add,\n if(current_size > 0, num_deleted / current_size, 0) AS percent_delete\n FROM\n (\n SELECT\n path,\n max(time) AS max_time,\n commit_hash,\n any(lines_added) AS num_added,\n any(lines_deleted) AS num_deleted,\n any(change_type) AS type\n FROM git.clickhouse_file_changes\n WHERE (change_type IN ('Add', 'Modify')) AND (file_extension IN ('h', 'cpp', 'sql'))\n GROUP BY\n path,\n commit_hash\n ORDER BY\n path ASC,\n max_time ASC\n )\n ),\n rewrites AS\n (\n SELECT\n *,\n any(max_time) OVER (PARTITION BY path ORDER BY max_time ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_rewrite,\n dateDiff('day', previous_rewrite, max_time) AS rewrite_days\n FROM changes\n WHERE (type = 'Modify') AND (percent_add >= 0.5) AND (percent_delete >= 0.5) AND (current_size > 50)\n )\nSELECT\n avgIf(rewrite_days, rewrite_days > 0) AS avg_rewrite_time,\n quantilesTimingIf(0.5)(rewrite_days, rewrite_days > 0) AS half_life\nFROM rewrites",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "COAZRFX2YFULDBXRQTCQ1S",
"name": "All commit messages for specific topic",
"group": "git",
"comment": "",
"query": "SELECT\n time,\n substring(commit_hash, 1, 11) AS commit,\n change_type,\n author,\n path,\n old_path,\n lines_added,\n lines_deleted,\n commit_message\nFROM git.clickhouse_file_changes\nWHERE path = 'src/Storages/StorageReplicatedMergeTree.cpp'\nORDER BY time DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "5AUH3VVENJ6CFEFWDKW5ZH",
"name": "Author with commits for the most number of consecutive days",
"group": "git",
"comment": "",
"query": "SELECT\n author,\n toStartOfDay(time) AS day\nFROM git.clickhouse_commits\nGROUP BY\n author,\n day\nORDER BY\n author ASC,\n day ASC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "7ARCDLHQCESYBP3INDPTVO",
"name": "Get one hash and time",
"group": "git",
"comment": "",
"query": "SELECT hash, time FROM git.clickhouse_commits ORDER BY time DESC LIMIT 1",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "AKS9SYLARFMZCHGAAQNEBN",
"name": "Review all line changes for specific topic",
"group": "git",
"comment": "",
"query": "SELECT\n time,\n substring(commit_hash, 1, 11) AS commit,\n sign,\n line_number_old,\n line_number_new,\n author,\n line\nFROM git.clickhouse_line_changes\nWHERE path = 'src/Storages/StorageReplicatedMergeTree.cpp'\nORDER BY line_number_new ASC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "2HNFWPCFWEEY92WTAPMA7W",
"name": "Find current active files",
"group": "git",
"comment": "",
"query": "SELECT path\nFROM\n(\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n)\nGROUP BY path\nHAVING (argMax(change_type, last_time) != 2) AND NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)') ORDER BY path\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "1OXCKMOH2JVMSHD3NS2WW6",
"name": "Find number of active files",
"group": "git",
"comment": "",
"query": "SELECT uniq(path)\nFROM\n(\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)') ORDER BY path\n)",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "SCXWMR9GBMJ9UNZYQXQBFA",
"name": "List of changes for renamed file",
"group": "git",
"comment": "",
"query": "SELECT\n change_type,\n path,\n old_path,\n time,\n commit_hash\n FROM git.clickhouse_file_changes\n WHERE (path = 'src/Functions/geometryFromColumn.h') OR (old_path = 'src/Functions/geometryFromColumn.h')\n",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "MHXPSBNPTDMJYR3OYSXVR7",
"name": "List files with most modifications",
"group": "git",
"comment": "",
"query": "WITH current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n )\nSELECT\n path,\n sum(lines_added) + sum(lines_deleted) AS modifications\nFROM git.clickhouse_file_changes\nWHERE (path IN (current_files)) AND (file_extension IN ('h', 'cpp', 'sql'))\nGROUP BY path\nORDER BY modifications DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "GED2STFSYJDRAA59H8RLIV",
"name": "Number of commits per week day",
"group": "geo",
"comment": "",
"query": "SELECT\n day_of_week,\n count() AS c\nFROM git.clickhouse_commits\nGROUP BY dayOfWeek(time) AS day_of_week",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "REZRXDVU7CAWT5WKNJSTNY",
"name": "History of subdirectory/file",
"group": "git",
"comment": "",
"query": "SELECT\n week,\n sum(lines_added) AS lines_added,\n sum(lines_deleted) AS lines_deleted,\n uniq(commit_hash) AS num_commits,\n uniq(author) AS authors\nFROM git.clickhouse_file_changes\nWHERE path LIKE 'src/Storages%'\nGROUP BY toStartOfWeek(time) AS week\nORDER BY week ASC\nLIMIT 10\n",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "CYQFNQNK9TAMPU2OZ8KG5Y",
"name": "List files with maximum number of authors",
"group": "git",
"comment": "",
"query": "WITH current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n )\nSELECT\n path,\n uniq(author) AS num_authors\nFROM git.clickhouse_file_changes\nWHERE path IN (current_files)\nGROUP BY path\nORDER BY num_authors DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "VWPBPGRZVGTHOCQYWNQZNT",
"name": "Oldest lines of code in the repository",
"group": "git",
"comment": "",
"query": "WITH current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n )\nSELECT\n any(path) AS file_path,\n line,\n max(time) AS latest_change,\n any(file_change_type)\nFROM git.clickhouse_line_changes\nWHERE path IN (current_files)\nGROUP BY line\nORDER BY latest_change ASC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "EONJVEYDCODCUZUF8SNB4Y",
"name": "Files with longest history",
"group": "git",
"comment": "",
"query": "WITH current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n )\nSELECT\n count() AS c,\n path,\n max(time) AS latest_change\nFROM git.clickhouse_file_changes\nWHERE path IN (current_files)\nGROUP BY path\nORDER BY c DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "BA4RZUXUHNQBH9YK7F2T9J",
"name": "Distribution of contribution per day of the month",
"group": "git",
"comment": "",
"query": "SELECT\n day,\n bar(docs_ratio * 1000, 0, 100, 100) AS bar\nFROM\n(\n SELECT\n day,\n countIf(file_extension IN ('h', 'cpp', 'sql')) AS code,\n countIf(file_extension = 'md') AS docs,\n docs / (code + docs) AS docs_ratio\n FROM git.clickhouse_line_changes\n WHERE (sign = 1) AND (file_extension IN ('h', 'cpp', 'sql', 'md'))\n GROUP BY dayOfMonth(time) AS day\n)",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "MT8WBABUKYBYSBA78W5TML",
"name": "Authors with the most diverse impact",
"group": "git",
"comment": "",
"query": "SELECT\n author,\n uniq(path) AS num_files\nFROM git.clickhouse_file_changes\nWHERE (change_type IN ('Add', 'Modify')) AND (file_extension IN ('h', 'cpp', 'sql'))\nGROUP BY author\nORDER BY num_files DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "4Q3D67FWRIVWTY8EIDDE5U",
"name": "Authors with most recent diverse contribution",
"group": "git",
"comment": "",
"query": "SELECT\n author,\n sum(num_files_commit) AS num_files\nFROM\n(\n SELECT\n author,\n commit_hash,\n uniq(path) AS num_files_commit,\n max(time) AS commit_time\n FROM git.clickhouse_file_changes\n WHERE (change_type IN ('Add', 'Modify')) AND (file_extension IN ('h', 'cpp', 'sql'))\n GROUP BY\n author,\n commit_hash\n ORDER BY\n author ASC,\n commit_time DESC\n LIMIT 3 BY author\n)\nGROUP BY author\nORDER BY num_files DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "OKGZBACRHVGCRAGCZAJKMF",
"name": "Favorite files for an author",
"group": "git",
"comment": "",
"query": "WITH current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n )\nSELECT\n path,\n count() AS c\nFROM git.clickhouse_file_changes\nWHERE (author = 'Alexey Milovidov') AND (path IN (current_files))\nGROUP BY path\nORDER BY c DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "P9PBDZGOSVTKXEXU73ZNAJ",
"name": "Favorite code files for an author",
"group": "git",
"comment": "",
"query": "SELECT\n base,\n count() AS c\nFROM git.clickhouse_file_changes\nWHERE (author = 'Alexey Milovidov') AND (file_extension IN ('h', 'cpp', 'sql'))\nGROUP BY basename(path) AS base\nORDER BY c DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "PVSDOHZYUMRDDUZFEYJC7J",
"name": "Largest files",
"group": "git",
"comment": "",
"query": "WITH current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n )\nSELECT\n path,\n sum(lines_added) - sum(lines_deleted) AS num_lines,\n uniqExact(author) AS num_authors,\n num_lines / num_authors AS lines_author_ratio\nFROM git.clickhouse_file_changes\nWHERE path IN (current_files)\nGROUP BY path\nORDER BY lines_author_ratio DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "BZHGWUIZMPZZUHS5XRBK2M",
"name": "Largest code files",
"group": "git",
"comment": "",
"query": "WITH current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n )\nSELECT\n path,\n sum(lines_added) - sum(lines_deleted) AS num_lines,\n uniqExact(author) AS num_authors,\n num_lines / num_authors AS lines_author_ratio\nFROM git.clickhouse_file_changes\nWHERE (path IN (current_files)) AND (file_extension IN ('h', 'cpp', 'sql'))\nGROUP BY path\nORDER BY lines_author_ratio DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "RMHHZEDHFUCBGRQVQA2732",
"name": "Largest recent code files with ",
"group": "git",
"comment": "",
"query": "WITH current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n )\nSELECT\n min(time) AS min_date,\n path,\n sum(lines_added) - sum(lines_deleted) AS num_lines,\n uniqExact(author) AS num_authors,\n num_lines / num_authors AS lines_author_ratio\nFROM git.clickhouse_file_changes\nWHERE (path IN (current_files)) AND (file_extension IN ('h', 'cpp', 'sql'))\nGROUP BY path\nHAVING min_date <= (now() - toIntervalYear(1))\nORDER BY lines_author_ratio DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "PF3KEMYG5CVLJGCFYQEGB1",
"name": "Commits distribution by weekday",
"group": "git",
"comment": "",
"query": "SELECT\n dayOfWeek,\n uniq(commit_hash) AS commits,\n sum(lines_added) AS lines_added,\n sum(lines_deleted) AS lines_deleted\nFROM git.clickhouse_file_changes\nWHERE path LIKE 'src/Functions%'\nGROUP BY toDayOfWeek(time) AS dayOfWeek",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "Q4VDVKEGHHRBCUJHNCVTF1",
"name": "Commits distribution by hour of the day",
"group": "git",
"comment": "",
"query": "SELECT\n hourOfDay,\n uniq(commit_hash) AS commits,\n sum(lines_added) AS lines_added,\n sum(lines_deleted) AS lines_deleted\nFROM git.clickhouse_file_changes\nWHERE path LIKE 'src/Functions%'\nGROUP BY toHour(time) AS hourOfDay",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "9AZ8CENV8N91YGW7T6IB68",
"name": "Charts commits distribution by hour of the day",
"group": "git",
"comment": "",
"query": "SELECT\n hourOfDay,\n bar(commits, 0, 400, 50) AS commits,\n bar(lines_added, 0, 30000, 50) AS lines_added,\n bar(lines_deleted, 0, 15000, 50) AS lines_deleted\nFROM\n(\n SELECT\n hourOfDay,\n uniq(commit_hash) AS commits,\n sum(lines_added) AS lines_added,\n sum(lines_deleted) AS lines_deleted\n FROM git.clickhouse_file_changes\n WHERE path LIKE 'src/Functions%'\n GROUP BY toHour(time) AS hourOfDay\n)",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "448O8GWAHY3EM6ZZ7AGLAM",
"name": "Authors that tends to rewrite other authors code",
"group": "git",
"comment": "",
"query": "SELECT\n prev_author || '(a)' as add_author,\n author || '(d)' as delete_author,\n count() AS c\nFROM git.clickhouse_line_changes\nWHERE (sign = -1) AND (file_extension IN ('h', 'cpp')) AND (line_type NOT IN ('Punct', 'Empty')) AND (author != prev_author) AND (prev_author != '')\nGROUP BY\n prev_author,\n author\nORDER BY c DESC\nLIMIT 1 BY prev_author\nLIMIT 100",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "WXPKFJCAHOKYKEVTWNFVCY",
"name": "Top contributors per week day",
"group": "git",
"comment": "",
"query": "SELECT\n day_of_week,\n author,\n count() AS c\nFROM git.clickhouse_commits\nGROUP BY\n dayOfWeek(time) AS day_of_week,\n author\nORDER BY\n day_of_week ASC,\n c DESC\nLIMIT 1 BY day_of_week",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "8YRJGHFTNJAWJ96XCJKKEH",
"name": "Top contributors per week day for last year",
"group": "git",
"comment": "",
"query": "SELECT\n day_of_week,\n author,\n count() AS c\nFROM git.clickhouse_commits\nWHERE time > (now() - toIntervalYear(1))\nGROUP BY\n dayOfWeek(time) AS day_of_week,\n author\nORDER BY\n day_of_week ASC,\n c DESC\nLIMIT 1 BY day_of_week",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "VQF4KMRDSUEXGS1JFVDJHV",
"name": "Top contributor each day as a fraction of the total work performed in the last year",
"group": "git",
"comment": "",
"query": "SELECT\n top_author.day_of_week,\n top_author.author,\n top_author.author_work / all_work.total_work AS top_author_percent\nFROM\n(\n SELECT\n day_of_week,\n author,\n sum(lines_added) + sum(lines_deleted) AS author_work\n FROM git.clickhouse_file_changes\n WHERE time > (now() - toIntervalYear(1))\n GROUP BY\n author,\n dayOfWeek(time) AS day_of_week\n ORDER BY\n day_of_week ASC,\n author_work DESC\n LIMIT 1 BY day_of_week\n) AS top_author\nINNER JOIN\n(\n SELECT\n day_of_week,\n sum(lines_added) + sum(lines_deleted) AS total_work\n FROM git.clickhouse_file_changes\n WHERE time > (now() - toIntervalYear(1))\n GROUP BY dayOfWeek(time) AS day_of_week\n) AS all_work USING (day_of_week)",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "6YWAUQYPZINZDJGBEZBNWG",
"name": "Distribution of code age across repository",
"group": "git",
"comment": "",
"query": "WITH current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n )\nSELECT\n concat(root, '/', sub_folder) AS folder,\n round(avg(days_present)) AS avg_age_of_files,\n min(days_present) AS min_age_files,\n max(days_present) AS max_age_files,\n count() AS c\nFROM\n(\n SELECT\n path,\n dateDiff('day', min(time), toDate('2022-11-03')) AS days_present\n FROM git.clickhouse_file_changes\n WHERE (path IN (current_files)) AND (file_extension IN ('h', 'cpp', 'sql'))\n GROUP BY path\n)\nGROUP BY\n splitByChar('/', path)[1] AS root,\n splitByChar('/', path)[2] AS sub_folder\nORDER BY\n root ASC,\n c DESC\nLIMIT 5 BY root\n",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "T4DTWTB36WFSEYAZLMGRNF",
"name": "Number of an authors contribution divided by the number of lines they have had removed by another contributor",
"group": "git",
"comment": "",
"query": "SELECT\n k,\n written_code.c,\n removed_code.c,\n removed_code.c / written_code.c AS remove_ratio\nFROM\n(\n SELECT\n author AS k,\n count() AS c\n FROM git.clickhouse_line_changes\n WHERE (sign = 1) AND (file_extension IN ('h', 'cpp')) AND (line_type NOT IN ('Punct', 'Empty'))\n GROUP BY k\n) AS written_code\nINNER JOIN\n(\n SELECT\n prev_author AS k,\n count() AS c\n FROM git.clickhouse_line_changes\n WHERE (sign = -1) AND (file_extension IN ('h', 'cpp')) AND (line_type NOT IN ('Punct', 'Empty')) AND (author != prev_author)\n GROUP BY k\n) AS removed_code USING (k)\nWHERE written_code.c > 1000\nORDER BY remove_ratio DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "5PL1QLNSH6QQTR8H9HINNP",
"name": "Files with most rewrites",
"group": "git",
"comment": "",
"query": "WITH\n current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n ),\n changes AS\n (\n SELECT\n path,\n max(time) AS max_time,\n commit_hash,\n any(lines_added) AS num_added,\n any(lines_deleted) AS num_deleted,\n any(change_type) AS type\n FROM git.clickhouse_file_changes\n WHERE (change_type IN ('Add', 'Modify')) AND (path IN (current_files)) AND (file_extension IN ('h', 'cpp', 'sql'))\n GROUP BY\n path,\n commit_hash\n ORDER BY\n path ASC,\n max_time ASC\n ),\n rewrites AS\n (\n SELECT\n path,\n commit_hash,\n max_time,\n type,\n num_added,\n num_deleted,\n sum(num_added - num_deleted) OVER (PARTITION BY path ORDER BY max_time ASC) AS current_size,\n if(current_size > 0, num_added / current_size, 0) AS percent_add,\n if(current_size > 0, num_deleted / current_size, 0) AS percent_delete\n FROM changes\n )\nSELECT\n path,\n count() AS num_rewrites\nFROM rewrites\nWHERE (type = 'Modify') AND (percent_add >= 0.5) AND (percent_delete >= 0.5) AND (current_size > 50)\nGROUP BY path\nORDER BY num_rewrites DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "GVF23LEZTNZI22BT8LZBBE",
"name": "Find weekday when the code have the highest chance to stay",
"group": "git",
"comment": "",
"query": "SELECT\n day_of_week_added,\n count() AS num,\n avg(days_present) AS avg_days_present\nFROM\n(\n SELECT\n added_code.line,\n added_code.time AS added_day,\n dateDiff('day', added_code.time, removed_code.time) AS days_present\n FROM\n (\n SELECT\n path,\n line,\n max(time) AS time\n FROM git.clickhouse_line_changes\n WHERE (sign = 1) AND (line_type NOT IN ('Punct', 'Empty'))\n GROUP BY\n path,\n line\n ) AS added_code\n INNER JOIN\n (\n SELECT\n path,\n line,\n max(time) AS time\n FROM git.clickhouse_line_changes\n WHERE (sign = -1) AND (line_type NOT IN ('Punct', 'Empty'))\n GROUP BY\n path,\n line\n ) AS removed_code USING (path, line)\n WHERE removed_code.time > added_code.time\n)\nGROUP BY dayOfWeek(added_day) AS day_of_week_added",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "3CYYT7HEHWRFHVCM9JCKSU",
"name": "Files sorted by average code age",
"group": "git",
"comment": "",
"query": "WITH\n current_files AS\n (\n SELECT path\n FROM\n (\n SELECT\n old_path AS path,\n max(time) AS last_time,\n 2 AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY old_path\n UNION ALL\n SELECT\n path,\n max(time) AS last_time,\n argMax(change_type, time) AS change_type\n FROM git.clickhouse_file_changes\n GROUP BY path\n )\n GROUP BY path\n HAVING (argMax(change_type, last_time) != 2) AND (NOT match(path, '(^dbms/)|(^libs/)|(^tests/testflows/)|(^programs/server/store/)'))\n ORDER BY path ASC\n ),\n lines_removed AS\n (\n SELECT\n added_code.path AS path,\n added_code.line,\n added_code.time AS added_day,\n dateDiff('day', added_code.time, removed_code.time) AS days_present\n FROM\n (\n SELECT\n path,\n line,\n max(time) AS time,\n any(file_extension) AS file_extension\n FROM git.clickhouse_line_changes\n WHERE (sign = 1) AND (line_type NOT IN ('Punct', 'Empty'))\n GROUP BY\n path,\n line\n ) AS added_code\n INNER JOIN\n (\n SELECT\n path,\n line,\n max(time) AS time\n FROM git.clickhouse_line_changes\n WHERE (sign = -1) AND (line_type NOT IN ('Punct', 'Empty'))\n GROUP BY\n path,\n line\n ) AS removed_code USING (path, line)\n WHERE (removed_code.time > added_code.time) AND (path IN (current_files)) AND (file_extension IN ('h', 'cpp', 'sql'))\n )\nSELECT\n path,\n avg(days_present) AS avg_code_age\nFROM lines_removed\nGROUP BY path\nORDER BY avg_code_age DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "JGKZSEQDPDTDKZXD3ZCGLE",
"name": "Authors who write more tests",
"group": "git",
"comment": "",
"query": "SELECT\n author,\n countIf((file_extension IN ('h', 'cpp', 'sql', 'sh', 'py', 'expect')) AND (path LIKE '%tests%')) AS test,\n countIf((file_extension IN ('h', 'cpp', 'sql')) AND (NOT (path LIKE '%tests%'))) AS code,\n code / (code + test) AS ratio_code\nFROM git.clickhouse_file_changes\nGROUP BY author\nHAVING code > 20\nORDER BY code DESC\nLIMIT 20",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "S5AJIIRGSUAY1JXEVHQDAK",
"name": "Plot distribution of authors who write more tests",
"group": "geo",
"comment": "",
"query": "WITH (\n SELECT histogram(10)(ratio_code) AS hist\n FROM\n (\n SELECT\n author,\n countIf((file_extension IN ('h', 'cpp', 'sql', 'sh', 'py', 'expect')) AND (path LIKE '%tests%')) AS test,\n countIf((file_extension IN ('h', 'cpp', 'sql')) AND (NOT (path LIKE '%tests%'))) AS code,\n code / (code + test) AS ratio_code\n FROM git.clickhouse_file_changes\n GROUP BY author\n HAVING code > 20\n ORDER BY code DESC\n LIMIT 20\n )\n ) AS hist\nSELECT\n arrayJoin(hist).1 AS lower,\n arrayJoin(hist).2 AS upper,\n bar(arrayJoin(hist).3, 0, 100, 500) AS bar",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "EXPHDIURBTOXXOK1TGNNYD",
"name": "Authors with most comments ratio",
"group": "git",
"comment": "",
"query": "SELECT\n author,\n avg(ratio_comments) AS avg_ratio_comments,\n sum(code) AS code\nFROM\n(\n SELECT\n author,\n commit_hash,\n countIf(line_type = 'Comment') AS comments,\n countIf(line_type = 'Code') AS code,\n if(comments > 0, comments / (comments + code), 0) AS ratio_comments\n FROM git.clickhouse_line_changes\n GROUP BY\n author,\n commit_hash\n)\nGROUP BY author\nORDER BY code DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "SBHEWR8XC4PRHY13HPPKCN",
"name": "Average time before code will be rewritten ",
"group": "git",
"comment": "",
"query": "WITH author_ratios_by_offset AS\n (\n SELECT\n author,\n dateDiff('week', start_dates.start_date, contributions.week) AS week_offset,\n ratio_code\n FROM\n (\n SELECT\n author,\n toStartOfWeek(min(time)) AS start_date\n FROM git.clickhouse_line_changes\n WHERE file_extension IN ('h', 'cpp', 'sql')\n GROUP BY author AS start_dates\n ) AS start_dates\n INNER JOIN\n (\n SELECT\n author,\n countIf(line_type = 'Code') AS code,\n countIf((line_type = 'Comment') OR (line_type = 'Punct')) AS comments,\n comments / (comments + code) AS ratio_code,\n toStartOfWeek(time) AS week\n FROM git.clickhouse_line_changes\n WHERE (file_extension IN ('h', 'cpp', 'sql')) AND (sign = 1)\n GROUP BY\n time,\n author\n HAVING code > 20\n ORDER BY\n author ASC,\n time ASC\n ) AS contributions USING (author)\n )\nSELECT\n week_offset,\n avg(ratio_code) AS avg_code_ratio\nFROM author_ratios_by_offset\nGROUP BY week_offset\nHAVING (week_offset % 10) = 0\nORDER BY week_offset ASC\nLIMIT 20\n",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "8PQNWEWHAJTGN6FTX59KH2",
"name": "Day of the month with most number of rewrites",
"group": "git",
"comment": "",
"query": "WITH\n changes AS\n (\n SELECT\n path,\n commit_hash,\n max_time,\n type,\n num_added,\n num_deleted,\n sum(num_added - num_deleted) OVER (PARTITION BY path ORDER BY max_time ASC) AS current_size,\n if(current_size > 0, num_added / current_size, 0) AS percent_add,\n if(current_size > 0, num_deleted / current_size, 0) AS percent_delete\n FROM\n (\n SELECT\n path,\n max(time) AS max_time,\n commit_hash,\n any(file_lines_added) AS num_added,\n any(file_lines_deleted) AS num_deleted,\n any(file_change_type) AS type\n FROM git.clickhouse_line_changes\n WHERE (file_change_type IN ('Add', 'Modify')) AND (file_extension IN ('h', 'cpp', 'sql'))\n GROUP BY\n path,\n commit_hash\n ORDER BY\n path ASC,\n max_time ASC\n )\n ),\n rewrites AS\n (\n SELECT any(max_time) OVER (PARTITION BY path ORDER BY max_time ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_rewrite\n FROM changes\n WHERE (type = 'Modify') AND (percent_add >= 0.5) AND (percent_delete >= 0.5) AND (current_size > 50)\n )\nSELECT\n dayOfWeek(previous_rewrite) AS dayOfWeek,\n count() AS num_re_writes\nFROM rewrites\nGROUP BY dayOfWeek",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "BKHLVVWN5SET1VTIFQ8JVK",
"name": "Authors with the most sticky code",
"group": "git",
"comment": "",
"query": "WITH\n changes AS\n (\n SELECT\n path,\n author,\n commit_hash,\n max_time,\n type,\n num_added,\n num_deleted,\n sum(num_added - num_deleted) OVER (PARTITION BY path ORDER BY max_time ASC) AS current_size,\n if(current_size > 0, num_added / current_size, 0) AS percent_add,\n if(current_size > 0, num_deleted / current_size, 0) AS percent_delete\n FROM\n (\n SELECT\n path,\n any(author) AS author,\n max(time) AS max_time,\n commit_hash,\n any(file_lines_added) AS num_added,\n any(file_lines_deleted) AS num_deleted,\n any(file_change_type) AS type\n FROM git.clickhouse_line_changes\n WHERE (file_change_type IN ('Add', 'Modify')) AND (file_extension IN ('h', 'cpp', 'sql'))\n GROUP BY\n path,\n commit_hash\n ORDER BY\n path ASC,\n max_time ASC\n )\n ),\n rewrites AS\n (\n SELECT\n *,\n any(max_time) OVER (PARTITION BY path ORDER BY max_time ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_rewrite,\n dateDiff('day', previous_rewrite, max_time) AS rewrite_days,\n any(author) OVER (PARTITION BY path ORDER BY max_time ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS prev_author\n FROM changes\n WHERE (type = 'Modify') AND (percent_add >= 0.5) AND (percent_delete >= 0.5) AND (current_size > 50)\n )\nSELECT\n prev_author,\n avg(rewrite_days) AS c,\n uniq(path) AS num_files\nFROM rewrites\nGROUP BY prev_author\nHAVING num_files > 2\nORDER BY c DESC\nLIMIT 10\n",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "S3E64UYCAMDAYJRSXINVFR",
"name": "Most consecutive days of commits by an author",
"group": "git",
"comment": "",
"query": "WITH commit_days AS\n (\n SELECT\n author,\n day,\n any(day) OVER (PARTITION BY author ORDER BY day ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_commit,\n dateDiff('day', previous_commit, day) AS days_since_last,\n if(days_since_last = 1, 1, 0) AS consecutive_day\n FROM\n (\n SELECT\n author,\n toStartOfDay(time) AS day\n FROM git.clickhouse_commits\n GROUP BY\n author,\n day\n ORDER BY\n author ASC,\n day ASC\n )\n )\nSELECT\n author,\n arrayMax(arrayMap(x -> length(x), arraySplit(x -> (x = 0), groupArray(consecutive_day)))) AS max_consecutive_days\nFROM commit_days\nGROUP BY author\nORDER BY max_consecutive_days DESC\nLIMIT 10",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "AKTW3Z8JZAPQ4H9BH2ZFRX",
"name": "Line by line commit history of a file",
"group": "git",
"comment": "",
"query": "SELECT\n time,\n path,\n old_path,\n commit_hash,\n commit_message\nFROM git.clickhouse_file_changes\nWHERE (path = 'src/Storages/StorageReplicatedMergeTree.cpp') AND (change_type = 'Rename')",
"chart": {
"type": "line"
},
"format": false,
"params": []
},
{
"id": "KB5KQJJFNBKHE5GBUJCP1B",