[Groonga-commit] groonga/groonga at d3bd111 [master] select: deprecate --column

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Fri May 20 09:21:55 JST 2016


Kouhei Sutou	2016-05-20 09:21:55 +0900 (Fri, 20 May 2016)

  New Revision: d3bd111d478252e36eb673b7744b738b7bac00b5
  https://github.com/groonga/groonga/commit/d3bd111d478252e36eb673b7744b738b7bac00b5

  Message:
    select: deprecate --column
    
    Use --columns instead. --column is still usable.

  Added files:
    test/command/suite/select/columns/stage/filtered/drilldown.expected
    test/command/suite/select/columns/stage/filtered/drilldown.test
    test/command/suite/select/columns/stage/filtered/filter.expected
    test/command/suite/select/columns/stage/filtered/filter.test
    test/command/suite/select/columns/stage/filtered/output_columns.expected
    test/command/suite/select/columns/stage/filtered/output_columns.test
    test/command/suite/select/columns/stage/filtered/sortby.expected
    test/command/suite/select/columns/stage/filtered/sortby.test
    test/command/suite/select/columns/stage/initial/filter.expected
    test/command/suite/select/columns/stage/initial/filter.test
    test/command/suite/select/columns/stage/initial/index.expected
    test/command/suite/select/columns/stage/initial/index.test
    test/command/suite/select/columns/window_function/record_number/ascending.expected
    test/command/suite/select/columns/window_function/record_number/ascending.test
    test/command/suite/select/columns/window_function/record_number/descending.expected
    test/command/suite/select/columns/window_function/record_number/descending.test
    test/command/suite/select/drilldown/labeled/columns/stage/initial/drilldown.expected
    test/command/suite/select/drilldown/labeled/columns/stage/initial/drilldown.test
    test/command/suite/select/drilldown/labeled/columns/stage/initial/output_columns.expected
    test/command/suite/select/drilldown/labeled/columns/stage/initial/output_columns.test
  Modified files:
    lib/proc/proc_select.c

  Modified: lib/proc/proc_select.c (+47 -19)
===================================================================
--- lib/proc/proc_select.c    2016-05-19 18:22:55 +0900 (19c0c3d)
+++ lib/proc/proc_select.c    2016-05-20 09:21:55 +0900 (97e12a9)
@@ -207,6 +207,7 @@ grn_column_data_init(grn_ctx *ctx,
 {
   void *column_raw;
   grn_column_data *column;
+  int added;
 
   if (!*columns) {
     *columns = grn_hash_create(ctx,
@@ -220,12 +221,17 @@ grn_column_data_init(grn_ctx *ctx,
   if (!*columns) {
     return GRN_FALSE;
   }
+
   grn_hash_add(ctx,
                *columns,
                label,
                label_len,
                &column_raw,
-               NULL);
+               &added);
+  if (!added) {
+    return GRN_TRUE;
+  }
+
   column = column_raw;
   column->label.value = label;
   column->label.length = label_len;
@@ -236,6 +242,7 @@ grn_column_data_init(grn_ctx *ctx,
   column->value.length = 0;
   column->window.sort_keys.value = NULL;
   column->window.sort_keys.length = 0;
+
   return GRN_TRUE;
 }
 
@@ -254,7 +261,7 @@ grn_column_data_fill(grn_ctx *ctx,
     if (!type) {
       GRN_PLUGIN_ERROR(ctx,
                        GRN_INVALID_ARGUMENT,
-                       "[select][column][%s][%.*s] unknown type: <%.*s>",
+                       "[select][columns][%s][%.*s] unknown type: <%.*s>",
                        grn_column_stage_name(column->stage),
                        (int)(column->label.length),
                        column->label.value,
@@ -268,7 +275,7 @@ grn_column_data_fill(grn_ctx *ctx,
       grn_inspect(ctx, &inspected, type);
       GRN_PLUGIN_ERROR(ctx,
                        GRN_INVALID_ARGUMENT,
-                       "[select][column][%s][%.*s] invalid type: %.*s",
+                       "[select][columns][%s][%.*s] invalid type: %.*s",
                        grn_column_stage_name(column->stage),
                        (int)(column->label.length),
                        column->label.value,
@@ -287,7 +294,7 @@ grn_column_data_fill(grn_ctx *ctx,
     grn_snprintf(error_message_tag,
                  GRN_TABLE_MAX_KEY_SIZE,
                  GRN_TABLE_MAX_KEY_SIZE,
-                 "[select][column][%s][%.*s]",
+                 "[select][columns][%s][%.*s]",
                  grn_column_stage_name(column->stage),
                  (int)(column->label.length),
                  column->label.value);
@@ -315,6 +322,7 @@ grn_column_data_collect(grn_ctx *ctx,
                         size_t prefix_label_len)
 {
   grn_hash_cursor *cursor = NULL;
+
   cursor = grn_hash_cursor_open(ctx, columns,
                                 NULL, 0, NULL, 0, 0, -1, 0);
   if (!cursor) {
@@ -324,25 +332,36 @@ grn_column_data_collect(grn_ctx *ctx,
   while (grn_hash_cursor_next(ctx, cursor)) {
     grn_column_data *column;
     char key_name[GRN_TABLE_MAX_KEY_SIZE];
-    grn_obj *type;
-    grn_obj *flags;
-    grn_obj *value;
+    grn_obj *type = NULL;
+    grn_obj *flags = NULL;
+    grn_obj *value = NULL;
     struct {
       grn_obj *sort_keys;
     } window;
 
+    window.sort_keys = NULL;
+
     grn_hash_cursor_get_value(ctx, cursor, (void **)&column);
 
-#define GET_VAR(name)                                                   \
-    grn_snprintf(key_name,                                              \
-                 GRN_TABLE_MAX_KEY_SIZE,                                \
-                 GRN_TABLE_MAX_KEY_SIZE,                                \
-                 "%.*scolumn[%.*s]." # name,                            \
-                 (int)prefix_label_len,                                 \
-                 prefix_label,                                          \
-                 (int)(column->label.length),                           \
-                 column->label.value);                                  \
-    name = grn_plugin_proc_get_var(ctx, user_data, key_name, -1);
+#define GET_VAR_RAW(parameter_key, name)                                \
+    if (!name) {                                                        \
+      grn_snprintf(key_name,                                            \
+                   GRN_TABLE_MAX_KEY_SIZE,                              \
+                   GRN_TABLE_MAX_KEY_SIZE,                              \
+                   "%.*s%s[%.*s]." # name,                              \
+                   (int)prefix_label_len,                               \
+                   prefix_label,                                        \
+                   parameter_key,                                       \
+                   (int)(column->label.length),                         \
+                   column->label.value);                                \
+      name = grn_plugin_proc_get_var(ctx, user_data, key_name, -1);     \
+    }
+
+#define GET_VAR(name) do {                      \
+      GET_VAR_RAW("columns", name);             \
+      /* For backward compatibility */          \
+      GET_VAR_RAW("column", name);              \
+    } while (GRN_FALSE)
 
     GET_VAR(type);
     GET_VAR(flags);
@@ -351,6 +370,8 @@ grn_column_data_collect(grn_ctx *ctx,
 
 #undef GET_VAR
 
+#undef GET_VAR_RAW
+
     grn_column_data_fill(ctx, column,
                          type, flags, value, window.sort_keys);
   }
@@ -381,12 +402,12 @@ static grn_bool
 grn_columns_collect(grn_ctx *ctx,
                     grn_user_data *user_data,
                     grn_columns *columns,
+                    const char *prefix,
                     const char *base_prefix,
                     size_t base_prefix_len)
 {
   grn_obj *vars;
   grn_table_cursor *cursor;
-  const char *prefix = "column[";
   size_t prefix_len;
   const char *suffix = "].stage";
   size_t suffix_len;
@@ -468,7 +489,14 @@ grn_columns_fill(grn_ctx *ctx,
                  const char *prefix,
                  size_t prefix_length)
 {
-  if (!grn_columns_collect(ctx, user_data, columns, prefix, prefix_length)) {
+  if (!grn_columns_collect(ctx, user_data, columns,
+                           "columns[", prefix, prefix_length)) {
+    return GRN_FALSE;
+  }
+
+  /* For backward compatibility */
+  if (!grn_columns_collect(ctx, user_data, columns,
+                           "column[", prefix, prefix_length)) {
     return GRN_FALSE;
   }
 

  Added: test/command/suite/select/columns/stage/filtered/drilldown.expected (+87 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/filtered/drilldown.expected    2016-05-20 09:21:55 +0900 (1df2399)
@@ -0,0 +1,87 @@
+plugin_register functions/number
+[[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]
+load --table Items
+[
+{"_key": "Book",  "price": 1498},
+{"_key": "Food",  "price": 898},
+{"_key": "Drink", "price": 600}
+]
+[[0,0.0,0.0],3]
+select Items   --columns[price_range].stage filtered   --columns[price_range].type UInt32   --columns[price_range].flags COLUMN_SCALAR   --columns[price_range].value 'number_classify(price, 500)'   --drilldown price_range
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        3
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "price_range",
+          "UInt32"
+        ],
+        [
+          "price",
+          "UInt32"
+        ]
+      ],
+      [
+        1,
+        "Book",
+        1000,
+        1498
+      ],
+      [
+        2,
+        "Food",
+        500,
+        898
+      ],
+      [
+        3,
+        "Drink",
+        500,
+        600
+      ]
+    ],
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_key",
+          "UInt32"
+        ],
+        [
+          "_nsubrecs",
+          "Int32"
+        ]
+      ],
+      [
+        1000,
+        1
+      ],
+      [
+        500,
+        2
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/columns/stage/filtered/drilldown.test (+18 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/filtered/drilldown.test    2016-05-20 09:21:55 +0900 (8961ca4)
@@ -0,0 +1,18 @@
+plugin_register functions/number
+
+table_create Items TABLE_HASH_KEY ShortText
+column_create Items price COLUMN_SCALAR UInt32
+
+load --table Items
+[
+{"_key": "Book",  "price": 1498},
+{"_key": "Food",  "price": 898},
+{"_key": "Drink", "price": 600}
+]
+
+select Items \
+  --columns[price_range].stage filtered \
+  --columns[price_range].type UInt32 \
+  --columns[price_range].flags COLUMN_SCALAR \
+  --columns[price_range].value 'number_classify(price, 500)' \
+  --drilldown price_range

  Added: test/command/suite/select/columns/stage/filtered/filter.expected (+56 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/filtered/filter.expected    2016-05-20 09:21:55 +0900 (54d327b)
@@ -0,0 +1,56 @@
+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": 1498},
+{"_key": "Food",  "price": 1198},
+{"_key": "Drink", "price": 600}
+]
+[[0,0.0,0.0],3]
+select Items   --filter 'price < 1200'   --output_columns _id,_key,price,filtered   --columns[filtered].stage filtered   --columns[filtered].type UInt32   --columns[filtered].flags COLUMN_SCALAR   --columns[filtered].value '_id'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        2
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "price",
+          "UInt32"
+        ],
+        [
+          "filtered",
+          "UInt32"
+        ]
+      ],
+      [
+        2,
+        "Food",
+        1198,
+        2
+      ],
+      [
+        3,
+        "Drink",
+        600,
+        3
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/columns/stage/filtered/filter.test (+17 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/filtered/filter.test    2016-05-20 09:21:55 +0900 (919f8c6)
@@ -0,0 +1,17 @@
+table_create Items TABLE_HASH_KEY ShortText
+column_create Items price COLUMN_SCALAR UInt32
+
+load --table Items
+[
+{"_key": "Book",  "price": 1498},
+{"_key": "Food",  "price": 1198},
+{"_key": "Drink", "price": 600}
+]
+
+select Items \
+  --filter 'price < 1200' \
+  --output_columns _id,_key,price,filtered \
+  --columns[filtered].stage filtered \
+  --columns[filtered].type UInt32 \
+  --columns[filtered].flags COLUMN_SCALAR \
+  --columns[filtered].value '_id'

  Added: test/command/suite/select/columns/stage/filtered/output_columns.expected (+41 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/filtered/output_columns.expected    2016-05-20 09:21:55 +0900 (0ca8687)
@@ -0,0 +1,41 @@
+table_create Memos TABLE_NO_KEY
+[[0,0.0,0.0],true]
+column_create Memos content COLUMN_SCALAR Text
+[[0,0.0,0.0],true]
+load --table Memos
+[
+{"content": "Groonga is fast."},
+{"content": "Mroonga is fast and easy to use."},
+{"content": "PGroonga is fast and easy to use."}
+]
+[[0,0.0,0.0],3]
+select Memos   --query 'content:@fast'   --columns[highlighted_content].stage filtered   --columns[highlighted_content].type Text   --columns[highlighted_content].flags COLUMN_SCALAR   --columns[highlighted_content].value 'highlight_html(content)'   --output_columns highlighted_content
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        3
+      ],
+      [
+        [
+          "highlighted_content",
+          "Text"
+        ]
+      ],
+      [
+        "Groonga is <span class=\"keyword\">fast</span>."
+      ],
+      [
+        "Mroonga is <span class=\"keyword\">fast</span> and easy to use."
+      ],
+      [
+        "PGroonga is <span class=\"keyword\">fast</span> and easy to use."
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/columns/stage/filtered/output_columns.test (+17 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/filtered/output_columns.test    2016-05-20 09:21:55 +0900 (b426736)
@@ -0,0 +1,17 @@
+table_create Memos TABLE_NO_KEY
+column_create Memos content COLUMN_SCALAR Text
+
+load --table Memos
+[
+{"content": "Groonga is fast."},
+{"content": "Mroonga is fast and easy to use."},
+{"content": "PGroonga is fast and easy to use."}
+]
+
+select Memos \
+  --query 'content:@fast' \
+  --columns[highlighted_content].stage filtered \
+  --columns[highlighted_content].type Text \
+  --columns[highlighted_content].flags COLUMN_SCALAR \
+  --columns[highlighted_content].value 'highlight_html(content)' \
+  --output_columns highlighted_content

  Added: test/command/suite/select/columns/stage/filtered/sortby.expected (+55 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/filtered/sortby.expected    2016-05-20 09:21:55 +0900 (38864db)
@@ -0,0 +1,55 @@
+plugin_register functions/string
+[[0,0.0,0.0],true]
+table_create Products TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+load --table Products
+[
+{"_key": "Groonga"},
+{"_key": "PGroonga"},
+{"_key": "Ruby"}
+]
+[[0,0.0,0.0],3]
+select Products   --columns[key_length].stage filtered   --columns[key_length].type UInt32   --columns[key_length].flags COLUMN_SCALAR   --columns[key_length].value 'string_length(_key)'   --sortby key_length
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        3
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "key_length",
+          "UInt32"
+        ]
+      ],
+      [
+        3,
+        "Ruby",
+        4
+      ],
+      [
+        1,
+        "Groonga",
+        7
+      ],
+      [
+        2,
+        "PGroonga",
+        8
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/columns/stage/filtered/sortby.test (+17 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/filtered/sortby.test    2016-05-20 09:21:55 +0900 (750352c)
@@ -0,0 +1,17 @@
+plugin_register functions/string
+
+table_create Products TABLE_HASH_KEY ShortText
+
+load --table Products
+[
+{"_key": "Groonga"},
+{"_key": "PGroonga"},
+{"_key": "Ruby"}
+]
+
+select Products \
+  --columns[key_length].stage filtered \
+  --columns[key_length].type UInt32 \
+  --columns[key_length].flags COLUMN_SCALAR \
+  --columns[key_length].value 'string_length(_key)' \
+  --sortby key_length

  Added: test/command/suite/select/columns/stage/initial/filter.expected (+65 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/initial/filter.expected    2016-05-20 09:21:55 +0900 (b2f3ade)
@@ -0,0 +1,65 @@
+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":  520},
+{"_key": "Pen",   "price":  510},
+{"_key": "Food",  "price":  500},
+{"_key": "Drink", "price":  300}
+]
+[[0,0.0,0.0],6]
+select Items   --columns[price_with_tax].stage initial   --columns[price_with_tax].type UInt32   --columns[price_with_tax].flags COLUMN_SCALAR   --columns[price_with_tax].value 'price * 1.08'   --filter 'price_with_tax > 550'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        3
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "price_with_tax",
+          "UInt32"
+        ],
+        [
+          "price",
+          "UInt32"
+        ]
+      ],
+      [
+        1,
+        "Book",
+        1080,
+        1000
+      ],
+      [
+        2,
+        "Note",
+        1080,
+        1000
+      ],
+      [
+        3,
+        "Box",
+        561,
+        520
+      ]
+    ]
+  ]
+]

  Added: test/command/suite/select/columns/stage/initial/filter.test (+19 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/initial/filter.test    2016-05-20 09:21:55 +0900 (c363d4c)
@@ -0,0 +1,19 @@
+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":  520},
+{"_key": "Pen",   "price":  510},
+{"_key": "Food",  "price":  500},
+{"_key": "Drink", "price":  300}
+]
+
+select Items \
+  --columns[price_with_tax].stage initial \
+  --columns[price_with_tax].type UInt32 \
+  --columns[price_with_tax].flags COLUMN_SCALAR \
+  --columns[price_with_tax].value 'price * 1.08' \
+  --filter 'price_with_tax > 550'

  Added: test/command/suite/select/columns/stage/initial/index.expected (+81 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/initial/index.expected    2016-05-20 09:21:55 +0900 (d521eb3)
@@ -0,0 +1,81 @@
+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]
+table_create Prices TABLE_PAT_KEY UInt32
+[[0,0.0,0.0],true]
+column_create Prices item_index COLUMN_INDEX Items price
+[[0,0.0,0.0],true]
+load --table Items
+[
+{"_key": "Book",  "price": 1000},
+{"_key": "Note",  "price": 1000},
+{"_key": "Box",   "price":  520},
+{"_key": "Pen",   "price":  510},
+{"_key": "Food",  "price":  500},
+{"_key": "Drink", "price":  300}
+]
+[[0,0.0,0.0],6]
+log_level --level info
+[[0,0.0,0.0],true]
+select Items   --columns[price_with_tax].stage initial   --columns[price_with_tax].type UInt32   --columns[price_with_tax].flags COLUMN_SCALAR   --columns[price_with_tax].value 'price * 1.08'   --filter 'price >= 510'
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        4
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "price_with_tax",
+          "UInt32"
+        ],
+        [
+          "price",
+          "UInt32"
+        ]
+      ],
+      [
+        4,
+        "Pen",
+        550,
+        510
+      ],
+      [
+        3,
+        "Box",
+        561,
+        520
+      ],
+      [
+        1,
+        "Book",
+        1080,
+        1000
+      ],
+      [
+        2,
+        "Note",
+        1080,
+        1000
+      ]
+    ]
+  ]
+]
+#|i| [table][select][index][range] <Prices>
+#|i| [table][select][index][range][accessor] <Prices.item_index>
+log_level --level notice
+[[0,0.0,0.0],true]

  Added: test/command/suite/select/columns/stage/initial/index.test (+26 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/stage/initial/index.test    2016-05-20 09:21:55 +0900 (848a745)
@@ -0,0 +1,26 @@
+table_create Items TABLE_HASH_KEY ShortText
+column_create Items price COLUMN_SCALAR UInt32
+
+table_create Prices TABLE_PAT_KEY UInt32
+column_create Prices item_index COLUMN_INDEX Items price
+
+load --table Items
+[
+{"_key": "Book",  "price": 1000},
+{"_key": "Note",  "price": 1000},
+{"_key": "Box",   "price":  520},
+{"_key": "Pen",   "price":  510},
+{"_key": "Food",  "price":  500},
+{"_key": "Drink", "price":  300}
+]
+
+#@add-important-log-levels info
+log_level --level info
+select Items \
+  --columns[price_with_tax].stage initial \
+  --columns[price_with_tax].type UInt32 \
+  --columns[price_with_tax].flags COLUMN_SCALAR \
+  --columns[price_with_tax].value 'price * 1.08' \
+  --filter 'price >= 510'
+log_level --level notice
+#@remove-important-log-levels info

  Added: test/command/suite/select/columns/window_function/record_number/ascending.expected (+73 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/window_function/record_number/ascending.expected    2016-05-20 09:21:55 +0900 (4cca7ab)
@@ -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 '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/record_number/ascending.test (+19 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/window_function/record_number/ascending.test    2016-05-20 09:21:55 +0900 (2d33789)
@@ -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 '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/record_number/descending.expected (+73 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/window_function/record_number/descending.expected    2016-05-20 09:21:55 +0900 (65b47a1)
@@ -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 '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/record_number/descending.test (+19 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/columns/window_function/record_number/descending.test    2016-05-20 09:21:55 +0900 (46dbb83)
@@ -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 '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/drilldown/labeled/columns/stage/initial/drilldown.expected (+171 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/drilldown/labeled/columns/stage/initial/drilldown.expected    2016-05-20 09:21:55 +0900 (e4eaa64)
@@ -0,0 +1,171 @@
+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]
+table_create Shops TABLE_HASH_KEY ShortText
+[[0,0.0,0.0],true]
+column_create Shops items COLUMN_VECTOR Items
+[[0,0.0,0.0],true]
+load --table Shops
+[
+{"_key": "Stationery store",  "items": ["Book", "Note", "Box", "Pen"]},
+{"_key": "Supermarket",       "items": ["Food", "Drink", "Pen"]},
+{"_key": "Convenience store", "items": ["Pen", "Note","Food", "Drink"]}
+]
+[[0,0.0,0.0],3]
+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 Shops   --drilldown[item].keys items   --drilldown[item].sortby price   --drilldown[item].output_columns _key,_nsubrecs,price,price_with_tax   --drilldown[item].columns[price_with_tax].stage initial   --drilldown[item].columns[price_with_tax].type UInt32   --drilldown[item].columns[price_with_tax].flags COLUMN_SCALAR   --drilldown[item].columns[price_with_tax].value 'price * 1.08'   --drilldown[real_price].table item   --drilldown[real_price].keys price_with_tax
+[
+  [
+    0,
+    0.0,
+    0.0
+  ],
+  [
+    [
+      [
+        3
+      ],
+      [
+        [
+          "_id",
+          "UInt32"
+        ],
+        [
+          "_key",
+          "ShortText"
+        ],
+        [
+          "items",
+          "Items"
+        ]
+      ],
+      [
+        1,
+        "Stationery store",
+        [
+          "Book",
+          "Note",
+          "Box",
+          "Pen"
+        ]
+      ],
+      [
+        2,
+        "Supermarket",
+        [
+          "Food",
+          "Drink",
+          "Pen"
+        ]
+      ],
+      [
+        3,
+        "Convenience store",
+        [
+          "Pen",
+          "Note",
+          "Food",
+          "Drink"
+        ]
+      ]
+    ],
+    {
+      "item": [
+        [
+          6
+        ],
+        [
+          [
+            "_key",
+            "ShortText"
+          ],
+          [
+            "_nsubrecs",
+            "Int32"
+          ],
+          [
+            "price",
+            "UInt32"
+          ],
+          [
+            "price_with_tax",
+            "UInt32"
+          ]
+        ],
+        [
+          "Drink",
+          2,
+          300,
+          324
+        ],
+        [
+          "Food",
+          2,
+          500,
+          540
+        ],
+        [
+          "Pen",
+          3,
+          500,
+          540
+        ],
+        [
+          "Box",
+          1,
+          500,
+          540
+        ],
+        [
+          "Book",
+          1,
+          1000,
+          1080
+        ],
+        [
+          "Note",
+          2,
+          1000,
+          1080
+        ]
+      ],
+      "real_price": [
+        [
+          3
+        ],
+        [
+          [
+            "_key",
+            "UInt32"
+          ],
+          [
+            "_nsubrecs",
+            "Int32"
+          ]
+        ],
+        [
+          1080,
+          2
+        ],
+        [
+          540,
+          3
+        ],
+        [
+          324,
+          1
+        ]
+      ]
+    }
+  ]
+]

  Added: test/command/suite/select/drilldown/labeled/columns/stage/initial/drilldown.test (+33 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/drilldown/labeled/columns/stage/initial/drilldown.test    2016-05-20 09:21:55 +0900 (974e5d1)
@@ -0,0 +1,33 @@
+table_create Items TABLE_HASH_KEY ShortText
+column_create Items price COLUMN_SCALAR UInt32
+
+table_create Shops TABLE_HASH_KEY ShortText
+column_create Shops items COLUMN_VECTOR Items
+
+load --table Shops
+[
+{"_key": "Stationery store",  "items": ["Book", "Note", "Box", "Pen"]},
+{"_key": "Supermarket",       "items": ["Food", "Drink", "Pen"]},
+{"_key": "Convenience store", "items": ["Pen", "Note","Food", "Drink"]}
+]
+
+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 Shops \
+  --drilldown[item].keys items \
+  --drilldown[item].sortby price \
+  --drilldown[item].output_columns _key,_nsubrecs,price,price_with_tax \
+  --drilldown[item].columns[price_with_tax].stage initial \
+  --drilldown[item].columns[price_with_tax].type UInt32 \
+  --drilldown[item].columns[price_with_tax].flags COLUMN_SCALAR \
+  --drilldown[item].columns[price_with_tax].value 'price * 1.08' \
+  --drilldown[real_price].table item \
+  --drilldown[real_price].keys price_with_tax

  Added: test/command/suite/select/drilldown/labeled/columns/stage/initial/output_columns.expected (+109 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/drilldown/labeled/columns/stage/initial/output_columns.expected    2016-05-20 09:21:55 +0900 (a198acd)
@@ -0,0 +1,109 @@
+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   --drilldown[label].keys price   --drilldown[label].output_columns _key,_nsubrecs,tax_included   --drilldown[label].columns[tax_included].stage initial   --drilldown[label].columns[tax_included].type UInt32   --drilldown[label].columns[tax_included].flags COLUMN_SCALAR   --drilldown[label].columns[tax_included].value '_key * 1.08'
+[
+  [
+    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": [
+        [
+          3
+        ],
+        [
+          [
+            "_key",
+            "UInt32"
+          ],
+          [
+            "_nsubrecs",
+            "Int32"
+          ],
+          [
+            "tax_included",
+            "UInt32"
+          ]
+        ],
+        [
+          1000,
+          2,
+          1080
+        ],
+        [
+          500,
+          3,
+          540
+        ],
+        [
+          300,
+          1,
+          324
+        ]
+      ]
+    }
+  ]
+]

  Added: test/command/suite/select/drilldown/labeled/columns/stage/initial/output_columns.test (+20 -0) 100644
===================================================================
--- /dev/null
+++ test/command/suite/select/drilldown/labeled/columns/stage/initial/output_columns.test    2016-05-20 09:21:55 +0900 (86fdd00)
@@ -0,0 +1,20 @@
+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 \
+  --drilldown[label].keys price \
+  --drilldown[label].output_columns _key,_nsubrecs,tax_included \
+  --drilldown[label].columns[tax_included].stage initial \
+  --drilldown[label].columns[tax_included].type UInt32 \
+  --drilldown[label].columns[tax_included].flags COLUMN_SCALAR \
+  --drilldown[label].columns[tax_included].value '_key * 1.08'
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index