Kouhei Sutou
null+****@clear*****
Tue Mar 21 20:47:23 JST 2017
Kouhei Sutou 2017-03-21 20:47:23 +0900 (Tue, 21 Mar 2017) New Revision: ef241d1bfafa04bd353cb606e1a603ca68cf720d https://github.com/groonga/groonga/commit/ef241d1bfafa04bd353cb606e1a603ca68cf720d Message: logical_select: support group_keys in window function Added files: test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/group_keys.expected test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/group_keys.test Modified files: plugins/sharding/logical_select.rb Modified: plugins/sharding/logical_select.rb (+3 -1) =================================================================== --- plugins/sharding/logical_select.rb 2017-03-21 20:41:30 +0900 (417f1df) +++ plugins/sharding/logical_select.rb 2017-03-21 20:47:23 +0900 (ec31a9d) @@ -420,6 +420,7 @@ module Groonga attr_reader :flags attr_reader :value attr_reader :window_sort_keys + attr_reader :window_group_keys def initialize(label, parameters) @label = label @stage = parameters["stage"] @@ -427,6 +428,7 @@ module Groonga @flags = parse_flags(parameters["flags"] || "COLUMN_SCALAR") @value = parameters["value"] @window_sort_keys = parameters["window.sort_keys"] + @window_group_keys = parameters["window.group_keys"] end def close @@ -437,7 +439,7 @@ module Groonga expression = Expression.create(table) begin expression.parse(@value) - if @window_sort_keys + if @window_sort_keys or @window_group_keys table.apply_window_function(column, expression, :sort_keys => @window_sort_keys, :group_keys => @window_group_keys) Added: test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/group_keys.expected (+136 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/group_keys.expected 2017-03-21 20:47:23 +0900 (c416e0c) @@ -0,0 +1,136 @@ +plugin_register sharding +[[0,0.0,0.0],true] +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] +column_create Items type COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +table_create Logs_20170315 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20170315 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Logs_20170315 item COLUMN_SCALAR Items +[[0,0.0,0.0],true] +table_create Logs_20170316 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20170316 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Logs_20170316 item COLUMN_SCALAR Items +[[0,0.0,0.0],true] +table_create Logs_20170317 TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Logs_20170317 timestamp COLUMN_SCALAR Time +[[0,0.0,0.0],true] +column_create Logs_20170317 item COLUMN_SCALAR Items +[[0,0.0,0.0],true] +load --table Items +[ +{"_key": "item1", "price": 666, "type": "C"}, +{"_key": "item2", "price": 999, "type": "A"}, +{"_key": "item3", "price": 777, "type": "A"}, +{"_key": "item4", "price": 111, "type": "B"}, +{"_key": "item5", "price": 333, "type": "C"}, +{"_key": "item6", "price": 222, "type": "A"} +] +[[0,0.0,0.0],6] +load --table Logs_20170315 +[ +{"timestamp": "2017/03/15 00:00:00", "item": "item1"}, +{"timestamp": "2017/03/15 01:00:00", "item": "item2"} +] +[[0,0.0,0.0],2] +load --table Logs_20170316 +[ +{"timestamp": "2017/03/16 10:00:00", "item": "item3"}, +{"timestamp": "2017/03/16 11:00:00", "item": "item4"} +] +[[0,0.0,0.0],2] +load --table Logs_20170317 +[ +{"timestamp": "2017/03/17 20:00:00", "item": "item5"}, +{"timestamp": "2017/03/17 20:00:00", "item": "item6"} +] +[[0,0.0,0.0],2] +logical_select Logs --shard_key timestamp --output_columns _id --limit 0 --drilldowns[item].keys item --drilldowns[item].columns[nth_record].stage initial --drilldowns[item].columns[nth_record].type UInt32 --drilldowns[item].columns[nth_record].flags COLUMN_SCALAR --drilldowns[item].columns[nth_record].value 'window_record_number()' --drilldowns[item].columns[nth_record].window.group_keys type --drilldowns[item].columns[nth_record].window.sort_keys price --drilldowns[item].sort_keys 'type, nth_record' --drilldowns[item].output_columns 'type, nth_record, _key, price' +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 6 + ], + [ + [ + "_id", + "UInt32" + ] + ] + ], + { + "item": [ + [ + 6 + ], + [ + [ + "type", + "ShortText" + ], + [ + "nth_record", + "UInt32" + ], + [ + "_key", + "ShortText" + ], + [ + "price", + "UInt32" + ] + ], + [ + "A", + 1, + "item6", + 222 + ], + [ + "A", + 2, + "item3", + 777 + ], + [ + "A", + 3, + "item2", + 999 + ], + [ + "B", + 1, + "item4", + 111 + ], + [ + "C", + 1, + "item5", + 333 + ], + [ + "C", + 2, + "item1", + 666 + ] + ] + } + ] +] Added: test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/group_keys.test (+61 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/group_keys.test 2017-03-21 20:47:23 +0900 (027d06b) @@ -0,0 +1,61 @@ +#@on-error omit +plugin_register sharding +#@on-error default + +table_create Items TABLE_HASH_KEY ShortText +column_create Items price COLUMN_SCALAR UInt32 +column_create Items type COLUMN_SCALAR ShortText + +table_create Logs_20170315 TABLE_NO_KEY +column_create Logs_20170315 timestamp COLUMN_SCALAR Time +column_create Logs_20170315 item COLUMN_SCALAR Items + +table_create Logs_20170316 TABLE_NO_KEY +column_create Logs_20170316 timestamp COLUMN_SCALAR Time +column_create Logs_20170316 item COLUMN_SCALAR Items + +table_create Logs_20170317 TABLE_NO_KEY +column_create Logs_20170317 timestamp COLUMN_SCALAR Time +column_create Logs_20170317 item COLUMN_SCALAR Items + +load --table Items +[ +{"_key": "item1", "price": 666, "type": "C"}, +{"_key": "item2", "price": 999, "type": "A"}, +{"_key": "item3", "price": 777, "type": "A"}, +{"_key": "item4", "price": 111, "type": "B"}, +{"_key": "item5", "price": 333, "type": "C"}, +{"_key": "item6", "price": 222, "type": "A"} +] + +load --table Logs_20170315 +[ +{"timestamp": "2017/03/15 00:00:00", "item": "item1"}, +{"timestamp": "2017/03/15 01:00:00", "item": "item2"} +] + +load --table Logs_20170316 +[ +{"timestamp": "2017/03/16 10:00:00", "item": "item3"}, +{"timestamp": "2017/03/16 11:00:00", "item": "item4"} +] + +load --table Logs_20170317 +[ +{"timestamp": "2017/03/17 20:00:00", "item": "item5"}, +{"timestamp": "2017/03/17 20:00:00", "item": "item6"} +] + +logical_select Logs \ + --shard_key timestamp \ + --output_columns _id \ + --limit 0 \ + --drilldowns[item].keys item \ + --drilldowns[item].columns[nth_record].stage initial \ + --drilldowns[item].columns[nth_record].type UInt32 \ + --drilldowns[item].columns[nth_record].flags COLUMN_SCALAR \ + --drilldowns[item].columns[nth_record].value 'window_record_number()' \ + --drilldowns[item].columns[nth_record].window.group_keys type \ + --drilldowns[item].columns[nth_record].window.sort_keys price \ + --drilldowns[item].sort_keys 'type, nth_record' \ + --drilldowns[item].output_columns 'type, nth_record, _key, price' -------------- next part -------------- HTML����������������������������...Download