[Groonga-commit] groonga/groonga at 40ce92d [master] logical_select: apply initial stage dynamic columns only in range

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jan 22 16:29:02 JST 2018


Kouhei Sutou	2018-01-22 16:29:02 +0900 (Mon, 22 Jan 2018)

  New Revision: 40ce92d6cfa7aebb767c15958fe57ced821cd9c4
  https://github.com/groonga/groonga/commit/40ce92d6cfa7aebb767c15958fe57ced821cd9c4

  Message:
    logical_select: apply initial stage dynamic columns only in range

  Added files:
    test/command/suite/sharding/logical_select/columns/stage/initial/range.expected
    test/command/suite/sharding/logical_select/columns/stage/initial/range.test
  Modified files:
    plugins/sharding/logical_select.rb

  Modified: plugins/sharding/logical_select.rb (+10 -1)
===================================================================
--- plugins/sharding/logical_select.rb    2018-01-22 16:20:48 +0900 (642b2aa48)
+++ plugins/sharding/logical_select.rb    2018-01-22 16:29:02 +0900 (e794f476b)
@@ -704,7 +704,16 @@ module Groonga
 
           @context.dynamic_columns.each_initial do |dynamic_column|
             if @target_table ==****@shard*****
-              @target_table = @target_table.select_all
+              if @cover_type == :all
+                @target_table = @target_table.select_all
+              else
+                expression_builder = RangeExpressionBuilder.new(shard_key,
+                                                                @target_range)
+                expression = create_expression(@target_table)
+                expression_builder.build(expression, @shard_range)
+                @target_table = @target_table.select(expression)
+                @cover_type = :all
+              end
               @context.temporary_tables << @target_table
             end
             dynamic_column.apply(@target_table)

  Added: test/command/suite/sharding/logical_select/columns/stage/initial/range.expected (+98 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_select/columns/stage/initial/range.expected    2018-01-22 16:29:02 +0900 (3a329f74b)
@@ -0,0 +1,98 @@
+plugin_register sharding
+[[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 price COLUMN_SCALAR UInt32
+[[0,0.0,0.0],true]
+column_create Logs_20170315 category COLUMN_SCALAR ShortText
+[[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 price COLUMN_SCALAR UInt32
+[[0,0.0,0.0],true]
+column_create Logs_20170316 category COLUMN_SCALAR ShortText
+[[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 price COLUMN_SCALAR UInt32
+[[0,0.0,0.0],true]
+column_create Logs_20170317 category COLUMN_SCALAR ShortText
+[[0,0.0,0.0],true]
+load --table Logs_20170315
+[
+{"timestamp": "2017/03/15 00:00:00", "price": 1000, "category": "X"},
+{"timestamp": "2017/03/15 01:00:00", "price":  900, "category": "X"}
+]
+[[0,0.0,0.0],2]
+load --table Logs_20170316
+[
+{"timestamp": "2017/03/16 10:00:00", "price":  520, "category": "X"},
+{"timestamp": "2017/03/16 11:00:00", "price":  510, "category": "X"}
+]
+[[0,0.0,0.0],2]
+load --table Logs_20170317
+[
+{"timestamp": "2017/03/17 20:00:00", "price":  500, "category": "X"},
+{"timestamp": "2017/03/17 20:00:00", "price":  300, "category": "X"}
+]
+[[0,0.0,0.0],2]
+logical_select Logs   --shard_key timestamp   --min "2017/03/15 01:00:00"   --min_border "include"   --max "2017/03/17 20:00:00"   --max_border "include"   --columns[price_sum_per_category].stage initial   --columns[price_sum_per_category].type UInt32   --columns[price_sum_per_category].flags COLUMN_SCALAR   --columns[price_sum_per_category].value 'window_sum(price)'   --columns[price_sum_per_category].window.group_keys 'category'   --output_columns _id,price,price_sum_per_category
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        5
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "price",
+          "UInt32"
+        ],
+        [
+          "price_sum_per_category",
+          "UInt32"
+        ]
+      ],
+      [
+        2,
+        900,
+        900
+      ],
+      [
+        1,
+        520,
+        1030
+      ],
+      [
+        2,
+        510,
+        1030
+      ],
+      [
+        1,
+        500,
+        800
+      ],
+      [
+        2,
+        300,
+        800
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/sharding/logical_select/columns/stage/initial/range.test (+49 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/sharding/logical_select/columns/stage/initial/range.test    2018-01-22 16:29:02 +0900 (ca111e02f)
@@ -0,0 +1,49 @@
+#@on-error omit
+plugin_register sharding
+#@on-error default
+
+table_create Logs_20170315 TABLE_NO_KEY
+column_create Logs_20170315 timestamp COLUMN_SCALAR Time
+column_create Logs_20170315 price COLUMN_SCALAR UInt32
+column_create Logs_20170315 category COLUMN_SCALAR ShortText
+
+table_create Logs_20170316 TABLE_NO_KEY
+column_create Logs_20170316 timestamp COLUMN_SCALAR Time
+column_create Logs_20170316 price COLUMN_SCALAR UInt32
+column_create Logs_20170316 category COLUMN_SCALAR ShortText
+
+table_create Logs_20170317 TABLE_NO_KEY
+column_create Logs_20170317 timestamp COLUMN_SCALAR Time
+column_create Logs_20170317 price COLUMN_SCALAR UInt32
+column_create Logs_20170317 category COLUMN_SCALAR ShortText
+
+load --table Logs_20170315
+[
+{"timestamp": "2017/03/15 00:00:00", "price": 1000, "category": "X"},
+{"timestamp": "2017/03/15 01:00:00", "price":  900, "category": "X"}
+]
+
+load --table Logs_20170316
+[
+{"timestamp": "2017/03/16 10:00:00", "price":  520, "category": "X"},
+{"timestamp": "2017/03/16 11:00:00", "price":  510, "category": "X"}
+]
+
+load --table Logs_20170317
+[
+{"timestamp": "2017/03/17 20:00:00", "price":  500, "category": "X"},
+{"timestamp": "2017/03/17 20:00:00", "price":  300, "category": "X"}
+]
+
+logical_select Logs \
+  --shard_key timestamp \
+  --min "2017/03/15 01:00:00" \
+  --min_border "include" \
+  --max "2017/03/17 20:00:00" \
+  --max_border "include" \
+  --columns[price_sum_per_category].stage initial \
+  --columns[price_sum_per_category].type UInt32 \
+  --columns[price_sum_per_category].flags COLUMN_SCALAR \
+  --columns[price_sum_per_category].value 'window_sum(price)' \
+  --columns[price_sum_per_category].window.group_keys 'category' \
+  --output_columns _id,price,price_sum_per_category
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180122/f62b06c6/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index