Navigation Menu

Skip to content

Commit

Permalink
Use "," for calc types separator
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 21, 2015
1 parent 50feaec commit 9da2c9b
Show file tree
Hide file tree
Showing 5 changed files with 257 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/proc.c
Expand Up @@ -598,7 +598,7 @@ grn_parse_table_group_calc_types(grn_ctx *ctx,
const char *calc_types_end = calc_types + calc_types_len;

while (calc_types < calc_types_end) {
if (*calc_types == '|' || *calc_types == ' ') {
if (*calc_types == ',' || *calc_types == ' ') {
calc_types += 1;
continue;
}
Expand Down
104 changes: 104 additions & 0 deletions test/command/suite/select/drilldown/labeled/calc_types/all.expected
@@ -0,0 +1,104 @@
table_create Tags TABLE_PAT_KEY ShortText
[[0,0.0,0.0],true]
table_create Memos TABLE_HASH_KEY ShortText
[[0,0.0,0.0],true]
column_create Memos tag COLUMN_SCALAR Tags
[[0,0.0,0.0],true]
column_create Memos priority COLUMN_SCALAR Int64
[[0,0.0,0.0],true]
load --table Memos
[
{"_key": "Groonga1", "tag": "Groonga", "priority": 10},
{"_key": "Groonga2", "tag": "Groonga", "priority": 20},
{"_key": "Groonga3", "tag": "Groonga", "priority": 60},
{"_key": "Mroonga1", "tag": "Mroonga", "priority": 61},
{"_key": "Mroonga2", "tag": "Mroonga", "priority": 24},
{"_key": "Mroonga3", "tag": "Mroonga", "priority": 8},
{"_key": "Rroonga1", "tag": "Rroonga", "priority": 3},
{"_key": "Rroonga2", "tag": "Rroonga", "priority": -9},
{"_key": "Rroonga3", "tag": "Rroonga", "priority": 0}
]
[[0,0.0,0.0],9]
select Memos --limit 0 --drilldown[tag].keys tag --drilldown[tag].calc_types 'AVG, MAX, MIN, SUM' --drilldown[tag].calc_target priority --drilldown[tag].output_columns _key,_max,_min,_sum,_avg
[
[
0,
0.0,
0.0
],
[
[
[
9
],
[
[
"_id",
"UInt32"
],
[
"_key",
"ShortText"
],
[
"priority",
"Int64"
],
[
"tag",
"Tags"
]
]
],
{
"tag": [
[
3
],
[
[
"_key",
"ShortText"
],
[
"_max",
"Int64"
],
[
"_min",
"Int64"
],
[
"_sum",
"Int64"
],
[
"_avg",
"Float"
]
],
[
"Groonga",
60,
10,
90,
30.0
],
[
"Mroonga",
61,
8,
93,
31.0
],
[
"Rroonga",
3,
-9,
-6,
-2.0
]
]
}
]
]
25 changes: 25 additions & 0 deletions test/command/suite/select/drilldown/labeled/calc_types/all.test
@@ -0,0 +1,25 @@
table_create Tags TABLE_PAT_KEY ShortText

table_create Memos TABLE_HASH_KEY ShortText
column_create Memos tag COLUMN_SCALAR Tags
column_create Memos priority COLUMN_SCALAR Int64

load --table Memos
[
{"_key": "Groonga1", "tag": "Groonga", "priority": 10},
{"_key": "Groonga2", "tag": "Groonga", "priority": 20},
{"_key": "Groonga3", "tag": "Groonga", "priority": 60},
{"_key": "Mroonga1", "tag": "Mroonga", "priority": 61},
{"_key": "Mroonga2", "tag": "Mroonga", "priority": 24},
{"_key": "Mroonga3", "tag": "Mroonga", "priority": 8},
{"_key": "Rroonga1", "tag": "Rroonga", "priority": 3},
{"_key": "Rroonga2", "tag": "Rroonga", "priority": -9},
{"_key": "Rroonga3", "tag": "Rroonga", "priority": 0}
]

select Memos \
--limit 0 \
--drilldown[tag].keys tag \
--drilldown[tag].calc_types 'AVG, MAX, MIN, SUM' \
--drilldown[tag].calc_target priority \
--drilldown[tag].output_columns _key,_max,_min,_sum,_avg
102 changes: 102 additions & 0 deletions test/command/suite/select/drilldown/plain/calc_types/all.expected
@@ -0,0 +1,102 @@
table_create Tags TABLE_PAT_KEY ShortText
[[0,0.0,0.0],true]
table_create Memos TABLE_HASH_KEY ShortText
[[0,0.0,0.0],true]
column_create Memos tag COLUMN_SCALAR Tags
[[0,0.0,0.0],true]
column_create Memos priority COLUMN_SCALAR Int64
[[0,0.0,0.0],true]
load --table Memos
[
{"_key": "Groonga1", "tag": "Groonga", "priority": 10},
{"_key": "Groonga2", "tag": "Groonga", "priority": 20},
{"_key": "Groonga3", "tag": "Groonga", "priority": 60},
{"_key": "Mroonga1", "tag": "Mroonga", "priority": 61},
{"_key": "Mroonga2", "tag": "Mroonga", "priority": 24},
{"_key": "Mroonga3", "tag": "Mroonga", "priority": 8},
{"_key": "Rroonga1", "tag": "Rroonga", "priority": 3},
{"_key": "Rroonga2", "tag": "Rroonga", "priority": -9},
{"_key": "Rroonga3", "tag": "Rroonga", "priority": 0}
]
[[0,0.0,0.0],9]
select Memos --limit 0 --drilldown tag --drilldown_calc_types 'MAX, MIN, SUM, AVG' --drilldown_calc_target priority --drilldown_output_columns _key,_max,_min,_sum,_avg
[
[
0,
0.0,
0.0
],
[
[
[
9
],
[
[
"_id",
"UInt32"
],
[
"_key",
"ShortText"
],
[
"priority",
"Int64"
],
[
"tag",
"Tags"
]
]
],
[
[
3
],
[
[
"_key",
"ShortText"
],
[
"_max",
"Int64"
],
[
"_min",
"Int64"
],
[
"_sum",
"Int64"
],
[
"_avg",
"Float"
]
],
[
"Groonga",
60,
10,
90,
30.0
],
[
"Mroonga",
61,
8,
93,
31.0
],
[
"Rroonga",
3,
-9,
-6,
-2.0
]
]
]
]
25 changes: 25 additions & 0 deletions test/command/suite/select/drilldown/plain/calc_types/all.test
@@ -0,0 +1,25 @@
table_create Tags TABLE_PAT_KEY ShortText

table_create Memos TABLE_HASH_KEY ShortText
column_create Memos tag COLUMN_SCALAR Tags
column_create Memos priority COLUMN_SCALAR Int64

load --table Memos
[
{"_key": "Groonga1", "tag": "Groonga", "priority": 10},
{"_key": "Groonga2", "tag": "Groonga", "priority": 20},
{"_key": "Groonga3", "tag": "Groonga", "priority": 60},
{"_key": "Mroonga1", "tag": "Mroonga", "priority": 61},
{"_key": "Mroonga2", "tag": "Mroonga", "priority": 24},
{"_key": "Mroonga3", "tag": "Mroonga", "priority": 8},
{"_key": "Rroonga1", "tag": "Rroonga", "priority": 3},
{"_key": "Rroonga2", "tag": "Rroonga", "priority": -9},
{"_key": "Rroonga3", "tag": "Rroonga", "priority": 0}
]

select Memos \
--limit 0 \
--drilldown tag \
--drilldown_calc_types 'MAX, MIN, SUM, AVG' \
--drilldown_calc_target priority \
--drilldown_output_columns _key,_max,_min,_sum,_avg

0 comments on commit 9da2c9b

Please sign in to comment.