You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user/ppl/cmd/chart.rst
+28-32Lines changed: 28 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
=============
1
+
=====
2
2
chart
3
-
=============
3
+
=====
4
4
5
5
.. rubric:: Table of contents
6
6
@@ -10,7 +10,7 @@ chart
10
10
11
11
12
12
Description
13
-
============
13
+
===========
14
14
15
15
The ``chart`` command transforms search results by applying a statistical aggregation function and optionally grouping the data by one or two fields. The results are suitable for visualization as a two-dimension chart when grouping by two fields, where unique values in the second group key can be pivoted to column names.
16
16
@@ -19,7 +19,7 @@ Version
19
19
3.4.0
20
20
21
21
Syntax
22
-
============
22
+
======
23
23
24
24
.. code-block:: text
25
25
@@ -34,62 +34,59 @@ Syntax
34
34
35
35
* Default: 10
36
36
* Syntax: ``limit=(top|bottom) <number>`` or ``limit=<number>`` (defaults to top)
37
-
* When there are more distinct values than the limit, the additional values are grouped into an "OTHER" category if useother is not set to false.
37
+
* When there are more distinct column split values than the limit, the additional values are grouped into an "OTHER" category if ``useother`` is not set to false.
38
38
* Set to 0 to show all distinct values without any limit.
39
-
* Only applies when using column split (over...by clause).
39
+
* Only applies when column split presents (by 2 fields or over...by... coexists).
40
40
41
-
* **useother**: optional. Controls whether to create an "OTHER" category for values beyond the limit.
41
+
* **useother**: optional. Controls whether to create an "OTHER" category for distinct column values beyond the limit.
42
42
43
43
* Default: true
44
-
* When set to false, only the top/bottom N values (based on limit) are shown without an "OTHER" category.
45
-
* When set to true, values beyond the limit are grouped into an "OTHER" category.
46
-
* Only applies when using column split and when there are more distinct values than the limit.
44
+
* When set to false, only the top/bottom N distinct values (based on limit) are shown without an "OTHER" category.
45
+
* When set to true, distinct values beyond the limit are grouped into an "OTHER" category.
46
+
* Only applies when using column split and when there are more distinct column values than the limit.
47
47
48
48
* **usenull**: optional. Controls whether to include null values as a separate category.
49
49
50
50
* Default: true
51
51
* When set to false, events with null values in the split-by field are excluded from results.
52
52
* When set to true, null values appear as a separate category.
53
53
54
-
* **nullstr**: optional. Specifies the string to display for null values.
54
+
* **nullstr**: optional. Specifies the category name for rows that do not contain the column split value.
55
55
56
56
* Default: "NULL"
57
-
* Only applies when usenull is set to true.
57
+
* Only applies when ``usenull`` is set to true.
58
58
59
-
* **otherstr**: optional. Specifies the string to display for the "OTHER" category.
59
+
* **otherstr**: optional. Specifies the category name for the "OTHER" category.
60
60
61
61
* Default: "OTHER"
62
-
* Only applies when useother is set to true and there are values beyond the limit.
62
+
* Only applies when ``useother`` is set to true and there are values beyond the limit.
63
63
64
64
* **aggregation_function**: mandatory. The aggregation function to apply to the data.
65
65
66
66
* Currently, only a single aggregation function is supported.
67
-
* Available functions: All aggregation functions supported by the :doc:`stats <stats>` command.
67
+
* Available functions: aggregation functions supported by the `stats <stats.rst>`_ command.
68
68
69
-
* **by**: optional. Groups the results by the specified field as rows.
69
+
* **by**: optional. Groups the results by either one field (row split) or two fields (row split and column split)
70
70
71
+
* ``limit``, ``useother``, and ``usenull`` apply to the column split
72
+
* Results are returned as individual rows for each combination.
71
73
* If not specified, the aggregation is performed across all documents.
72
74
73
-
* **over...by**: optional. Alternative syntax for grouping by multiple fields.
75
+
* **over...by...**: optional. Alternative syntax for grouping by multiple fields.
74
76
75
77
* ``over <row_split> by <column_split>`` groups the results by both fields.
76
-
* The row_split field becomes the primary grouping dimension.
77
-
* The column_split field becomes the secondary grouping dimension.
78
-
* Results are returned as individual rows for each combination.
78
+
* Using ``over`` alone on one field is equivalent to ``by <row-split>``
79
79
80
80
Notes
81
81
=====
82
82
83
-
* The ``chart`` command transforms results into a table format suitable for visualization.
84
-
* When using multiple grouping fields (over...by syntax), the output contains individual rows for each combination of the grouping fields.
85
-
* The limit parameter determines how many columns to show when there are many distinct values.
86
-
* Results are ordered by the aggregated values to determine top/bottom selections.
83
+
* The column split field in the result will become strings so that they are compatible with ``nullstr`` and ``otherstr`` and can be used as column names once pivoted.
87
84
88
85
Examples
89
86
========
90
87
91
88
Example 1: Basic aggregation without grouping
92
-
==============================================
89
+
---------------------------------------------
93
90
94
91
This example calculates the average balance across all accounts.
95
92
@@ -104,7 +101,7 @@ PPL query::
104
101
+--------------+
105
102
106
103
Example 2: Group by single field
107
-
=================================
104
+
--------------------------------
108
105
109
106
This example calculates the count of accounts grouped by gender.
110
107
@@ -120,7 +117,7 @@ PPL query::
120
117
+---------+--------+
121
118
122
119
Example 3: Using over and by for multiple field grouping
0 commit comments