Skip to content

Commit

Permalink
select: support fitered stage of dynamic columns on drilldowns
Browse files Browse the repository at this point in the history
  • Loading branch information
naoa committed May 10, 2020
1 parent f717fe4 commit e73de41
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/proc/proc_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -2657,6 +2657,16 @@ grn_select_drilldown_execute(grn_ctx *ctx,
grn_table_size(ctx, drilldown->filtered_result));
}

if (drilldown->columns.filtered) {
grn_select_apply_columns(ctx,
data,
drilldown->filtered_result,
drilldown->columns.filtered,
condition,
GRN_TEXT_VALUE(&log_tag_prefix),
GRN_TEXT_VALUE(&full_query_log_tag_prefix));
}

{
grn_obj *adjuster_result_table;
if (drilldown->filtered_result) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
table_create Items TABLE_HASH_KEY ShortText
[[0,0.0,0.0],true]
column_create Items price COLUMN_SCALAR UInt32
[[0,0.0,0.0],true]
load --table Items
[
{"_key": "Book", "price": 1000},
{"_key": "Note", "price": 1000},
{"_key": "Box", "price": 500},
{"_key": "Pen", "price": 500},
{"_key": "Food", "price": 500},
{"_key": "Drink", "price": 300}
]
[[0,0.0,0.0],6]
select Items --drilldowns[label].keys price --drilldowns[label].output_columns _key,_nsubrecs,nth_record --drilldowns[label].filter '_key >= 500' --drilldowns[label].columns[nth_record].stage filtered --drilldowns[label].columns[nth_record].type UInt32 --drilldowns[label].columns[nth_record].flags COLUMN_SCALAR --drilldowns[label].columns[nth_record].value 'window_record_number()' --drilldowns[label].columns[nth_record].window.sort_keys _key
[
[
0,
0.0,
0.0
],
[
[
[
6
],
[
[
"_id",
"UInt32"
],
[
"_key",
"ShortText"
],
[
"price",
"UInt32"
]
],
[
1,
"Book",
1000
],
[
2,
"Note",
1000
],
[
3,
"Box",
500
],
[
4,
"Pen",
500
],
[
5,
"Food",
500
],
[
6,
"Drink",
300
]
],
{
"label": [
[
2
],
[
[
"_key",
"UInt32"
],
[
"_nsubrecs",
"Int32"
],
[
"nth_record",
"UInt32"
]
],
[
1000,
2,
2
],
[
500,
3,
1
]
]
}
]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table_create Items TABLE_HASH_KEY ShortText
column_create Items price COLUMN_SCALAR UInt32

load --table Items
[
{"_key": "Book", "price": 1000},
{"_key": "Note", "price": 1000},
{"_key": "Box", "price": 500},
{"_key": "Pen", "price": 500},
{"_key": "Food", "price": 500},
{"_key": "Drink", "price": 300}
]

select Items \
--drilldowns[label].keys price \
--drilldowns[label].output_columns _key,_nsubrecs,nth_record \
--drilldowns[label].filter '_key >= 500' \
--drilldowns[label].columns[nth_record].stage filtered \
--drilldowns[label].columns[nth_record].type UInt32 \
--drilldowns[label].columns[nth_record].flags COLUMN_SCALAR \
--drilldowns[label].columns[nth_record].value 'window_record_number()' \
--drilldowns[label].columns[nth_record].window.sort_keys _key

0 comments on commit e73de41

Please sign in to comment.