summaryrefslogtreecommitdiffstats
path: root/fluent-bit/tests/internal/include/sp_select_subkeys.h
blob: a5feebf01869250f2dfecbd930410ea39d54da74 (plain)
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
#include "sp_cb_functions.h"

#ifndef FLB_TEST_SP_SELECT_SUBKEYS
#define FLB_TEST_SP_SELECT_SUBKEYS

/* Tests for 'test_select_subkeys' */
struct task_check select_subkeys_checks[] = {
    {
        0, 0, 0, 0,
        "select_sub_blue",
        "SELECT * FROM STREAM:FLB WHERE map['sub1']['sub2']['color'] = 'blue';",
        cb_select_sub_blue
    },
    {
        1, 0, 0, 0,
        "select_sub_num",
        "SELECT * FROM STREAM:FLB WHERE map['sub1']['sub2'] = 123;",
        cb_select_sub_num
    },
    {
        2, 0, 0, 0,
        "select_sub_colors",
        "SELECT * FROM STREAM:FLB WHERE "            \
        "map['sub1']['sub2']['color'] = 'blue' OR "  \
        "map['sub1']['sub2']['color'] = 'red'  OR "  \
        "map['color'] = 'blue'; ",
        cb_select_sub_colors
    },
    {
        3, 0, 0, 0,
        "cb_select_sub_record_contains",
        "SELECT * FROM STREAM:FLB WHERE "            \
        "@record.contains(map['sub1']['sub3']) OR "  \
        "@record.contains(map['color']); ",
        cb_select_sub_record_contains
    },
    {   4, 0, 0, 0,
        "cb_select_sub_keys",
        "SELECT map['sub1']['sub2']['color'] FROM STREAM:FLB WHERE "    \
        "map['sub1']['sub2']['color'] = 'blue';",
        cb_select_sub_keys},
    {   5, 0, 0, 0,
        "cb_select_sum_sub_keys",
        "SELECT SUM(map['sub1']['sub2']) FROM STREAM:FLB WHERE "    \
        "map['sub1']['sub2'] = 123;",
        cb_select_sum_sub_keys},
    {   6, 0, 0, 0,
        "cb_select_avg_sub_keys",
        "SELECT AVG(map['sub1']['sub2']) FROM STREAM:FLB WHERE "    \
        "map['sub1']['sub2'] = 123;",
        cb_select_avg_sub_keys},
    {   7, 0, 0, 0,
        "cb_select_count_sub_keys",
        "SELECT COUNT(map['sub1']['sub2']) FROM STREAM:FLB WHERE "    \
        "map['sub1']['sub2'] = 123;",
        cb_select_count_sub_keys},
    {   8, 0, 0, 0,
        "cb_select_min_sub_keys",
        "SELECT MIN(map['sub1']['sub2']) FROM STREAM:FLB WHERE "  \
        "map['sub1']['sub2'] > 0;",
        cb_select_min_sub_keys},
    {   9, 0, 0, 0,
        "cb_select_max_sub_keys",
        "SELECT MAX(map['sub1']['sub3']) FROM STREAM:FLB WHERE "  \
        "map['sub1']['sub3'] > 0;",
        cb_select_max_sub_keys},
    {   10, 0, 0, 0,
        "cb_select_sum_sub_keys_group_by",
        "SELECT SUM(map['sub1']['sub3']) FROM STREAM:FLB "  \
        "GROUP BY map['mtype'];",
        cb_select_sum_sub_keys_group_by},
    {   11, 0, 0, 0,
        "cb_select_sum_sub_keys_group_by_2",
        "SELECT map['sub1']['stype'], map['mtype'], SUM(map['sub1']['sub3']) " \
        "FROM STREAM:FLB GROUP BY map['mtype'], map['sub1']['stype'];",
        cb_select_sum_sub_keys_group_by_2},
    {   12, 0, 0, 0,
        "cb_select_sum_sub_keys_group_by_3",
        "SELECT map['sub1']['stype'], map['sub1']['sub4'], SUM(map['sub1']['sub3']) " \
        "FROM STREAM:FLB GROUP BY map['sub1']['stype'], map['sub1']['sub4'];",
        cb_select_sum_sub_keys_group_by_3}
};

#endif