Kouhei Sutou
null+****@clear*****
Wed Mar 29 14:53:42 JST 2017
Kouhei Sutou 2017-03-29 14:53:42 +0900 (Wed, 29 Mar 2017) New Revision: d67d6649e209f3641e1a886694bb5ac199b330ae https://github.com/groonga/groonga/commit/d67d6649e209f3641e1a886694bb5ac199b330ae Message: logical_select: support multiple window.sort_keys and window.group_keys Added files: test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/multiple_sort_keys.expected test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/multiple_sort_keys.test Modified files: plugins/sharding/logical_select.rb Modified: plugins/sharding/logical_select.rb (+4 -2) =================================================================== --- plugins/sharding/logical_select.rb 2017-03-29 14:53:17 +0900 (ec31a9d) +++ plugins/sharding/logical_select.rb 2017-03-29 14:53:42 +0900 (2a14fdc) @@ -414,6 +414,8 @@ module Groonga end class DynamicColumnExecuteContext + include KeysParsable + attr_reader :label attr_reader :stage attr_reader :type @@ -427,8 +429,8 @@ module Groonga @type = parse_type(parameters["type"]) @flags = parse_flags(parameters["flags"] || "COLUMN_SCALAR") @value = parameters["value"] - @window_sort_keys = parameters["window.sort_keys"] - @window_group_keys = parameters["window.group_keys"] + @window_sort_keys = parse_keys(parameters["window.sort_keys"]) + @window_group_keys = parse_keys(parameters["window.group_keys"]) end def close Added: test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/multiple_sort_keys.expected (+136 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/multiple_sort_keys.expected 2017-03-29 14:53:42 +0900 (9187361) @@ -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.sort_keys type,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", + 4, + "item4", + 111 + ], + [ + "C", + 5, + "item5", + 333 + ], + [ + "C", + 6, + "item1", + 666 + ] + ] + } + ] +] Added: test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/multiple_sort_keys.test (+60 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/sharding/logical_select/drilldowns/columns/window_function/window_record_number/multiple_sort_keys.test 2017-03-29 14:53:42 +0900 (9412270) @@ -0,0 +1,60 @@ +#@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.sort_keys type,price \ + --drilldowns[item].sort_keys 'type, nth_record' \ + --drilldowns[item].output_columns 'type, nth_record, _key, price' -------------- next part -------------- HTML����������������������������...Download