[Groonga-commit] groonga/groonga at 83ac201 [master] Add "window_" prefix for windows functions

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Jan 29 22:55:27 JST 2017


Kouhei Sutou	2017-01-29 22:55:27 +0900 (Sun, 29 Jan 2017)

  New Revision: 83ac2015873606fe94af452045d0b1d6bd8bc11a
  https://github.com/groonga/groonga/commit/83ac2015873606fe94af452045d0b1d6bd8bc11a

  Message:
    Add "window_" prefix for windows functions
    
    "record_number" is deprecated but it's still available for backward
    compatibility.

  Added files:
    test/command/suite/select/columns/window_function/window_record_number/ascending.expected
    test/command/suite/select/columns/window_function/window_record_number/ascending.test
    test/command/suite/select/columns/window_function/window_record_number/descending.expected
    test/command/suite/select/columns/window_function/window_record_number/descending.test
  Modified files:
    lib/window_functions.c

  Modified: lib/window_functions.c (+10 -6)
===================================================================
--- lib/window_functions.c    2017-01-29 22:46:23 +0900 (39126bd)
+++ lib/window_functions.c    2017-01-29 22:55:27 +0900 (2f5b219)
@@ -20,11 +20,11 @@
 #include "grn_window_functions.h"
 
 static grn_rc
-window_function_record_number(grn_ctx *ctx,
-                              grn_obj *output_column,
-                              grn_window *window,
-                              grn_obj **args,
-                              int n_args)
+window_record_number(grn_ctx *ctx,
+                     grn_obj *output_column,
+                     grn_window *window,
+                     grn_obj **args,
+                     int n_args)
 {
   grn_id id;
   uint32_t nth_record = 1;
@@ -44,8 +44,12 @@ window_function_record_number(grn_ctx *ctx,
 grn_rc
 grn_db_init_builtin_window_functions(grn_ctx *ctx)
 {
+  /* For backward compatibility. */
   grn_window_function_create(ctx,
                              "record_number", -1,
-                             window_function_record_number);
+                             window_record_number);
+  grn_window_function_create(ctx,
+                             "window_record_number", -1,
+                             window_record_number);
   return GRN_SUCCESS;
 }

  Added: test/command/suite/select/columns/window_function/window_record_number/ascending.expected (+73 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/window_function/window_record_number/ascending.expected    2017-01-29 22:55:27 +0900 (5337c88)
@@ -0,0 +1,73 @@
+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": "item1", "price": 666},
+{"_key": "item2", "price": 999},
+{"_key": "item3", "price": 777},
+{"_key": "item4", "price": 111},
+{"_key": "item5", "price": 333},
+{"_key": "item6", "price": 222}
+]
+[[0,0.0,0.0],6]
+select Items   --columns[nth_record].stage initial   --columns[nth_record].value 'window_record_number()'   --columns[nth_record].type UInt32   --columns[nth_record].window.sort_keys price   --output_columns '_key, price, nth_record'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        6
+      ],
+      [
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "price",
+          "UInt32"
+        ],
+        [
+          "nth_record",
+          "UInt32"
+        ]
+      ],
+      [
+        "item1",
+        666,
+        4
+      ],
+      [
+        "item2",
+        999,
+        6
+      ],
+      [
+        "item3",
+        777,
+        5
+      ],
+      [
+        "item4",
+        111,
+        1
+      ],
+      [
+        "item5",
+        333,
+        3
+      ],
+      [
+        "item6",
+        222,
+        2
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/columns/window_function/window_record_number/ascending.test (+19 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/window_function/window_record_number/ascending.test    2017-01-29 22:55:27 +0900 (a991ff6)
@@ -0,0 +1,19 @@
+table_create Items TABLE_HASH_KEY ShortText
+column_create Items price COLUMN_SCALAR UInt32
+
+load --table Items
+[
+{"_key": "item1", "price": 666},
+{"_key": "item2", "price": 999},
+{"_key": "item3", "price": 777},
+{"_key": "item4", "price": 111},
+{"_key": "item5", "price": 333},
+{"_key": "item6", "price": 222}
+]
+
+select Items \
+  --columns[nth_record].stage initial \
+  --columns[nth_record].value 'window_record_number()' \
+  --columns[nth_record].type UInt32 \
+  --columns[nth_record].window.sort_keys price \
+  --output_columns '_key, price, nth_record'

  Added: test/command/suite/select/columns/window_function/window_record_number/descending.expected (+73 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/window_function/window_record_number/descending.expected    2017-01-29 22:55:27 +0900 (51f6f5b)
@@ -0,0 +1,73 @@
+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": "item1", "price": 666},
+{"_key": "item2", "price": 999},
+{"_key": "item3", "price": 777},
+{"_key": "item4", "price": 111},
+{"_key": "item5", "price": 333},
+{"_key": "item6", "price": 222}
+]
+[[0,0.0,0.0],6]
+select Items   --columns[nth_record].stage initial   --columns[nth_record].value 'window_record_number()'   --columns[nth_record].type UInt32   --columns[nth_record].window.sort_keys -price   --output_columns '_key, price, nth_record'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        6
+      ],
+      [
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "price",
+          "UInt32"
+        ],
+        [
+          "nth_record",
+          "UInt32"
+        ]
+      ],
+      [
+        "item1",
+        666,
+        3
+      ],
+      [
+        "item2",
+        999,
+        1
+      ],
+      [
+        "item3",
+        777,
+        2
+      ],
+      [
+        "item4",
+        111,
+        6
+      ],
+      [
+        "item5",
+        333,
+        4
+      ],
+      [
+        "item6",
+        222,
+        5
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/columns/window_function/window_record_number/descending.test (+19 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/window_function/window_record_number/descending.test    2017-01-29 22:55:27 +0900 (b67af9f)
@@ -0,0 +1,19 @@
+table_create Items TABLE_HASH_KEY ShortText
+column_create Items price COLUMN_SCALAR UInt32
+
+load --table Items
+[
+{"_key": "item1", "price": 666},
+{"_key": "item2", "price": 999},
+{"_key": "item3", "price": 777},
+{"_key": "item4", "price": 111},
+{"_key": "item5", "price": 333},
+{"_key": "item6", "price": 222}
+]
+
+select Items \
+  --columns[nth_record].stage initial \
+  --columns[nth_record].value 'window_record_number()' \
+  --columns[nth_record].type UInt32 \
+  --columns[nth_record].window.sort_keys -price \
+  --output_columns '_key, price, nth_record'
-------------- next part --------------
HTML����������������������������...
Download 



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