Skip to content

Commit e0c92e1

Browse files
committed
Tweak chart.rst
Signed-off-by: Yuanchun Shen <[email protected]>
1 parent dbaa7f8 commit e0c92e1

File tree

1 file changed

+28
-32
lines changed

1 file changed

+28
-32
lines changed

docs/user/ppl/cmd/chart.rst

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
=============
1+
=====
22
chart
3-
=============
3+
=====
44

55
.. rubric:: Table of contents
66

@@ -10,7 +10,7 @@ chart
1010

1111

1212
Description
13-
============
13+
===========
1414

1515
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.
1616

@@ -19,7 +19,7 @@ Version
1919
3.4.0
2020

2121
Syntax
22-
============
22+
======
2323

2424
.. code-block:: text
2525
@@ -34,62 +34,59 @@ Syntax
3434

3535
* Default: 10
3636
* 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.
3838
* 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).
4040

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.
4242

4343
* 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.
4747

4848
* **usenull**: optional. Controls whether to include null values as a separate category.
4949

5050
* Default: true
5151
* When set to false, events with null values in the split-by field are excluded from results.
5252
* When set to true, null values appear as a separate category.
5353

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.
5555

5656
* Default: "NULL"
57-
* Only applies when usenull is set to true.
57+
* Only applies when ``usenull`` is set to true.
5858

59-
* **otherstr**: optional. Specifies the string to display for the "OTHER" category.
59+
* **otherstr**: optional. Specifies the category name for the "OTHER" category.
6060

6161
* 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.
6363

6464
* **aggregation_function**: mandatory. The aggregation function to apply to the data.
6565

6666
* 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.
6868

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)
7070

71+
* ``limit``, ``useother``, and ``usenull`` apply to the column split
72+
* Results are returned as individual rows for each combination.
7173
* If not specified, the aggregation is performed across all documents.
7274

73-
* **over...by**: optional. Alternative syntax for grouping by multiple fields.
75+
* **over...by...**: optional. Alternative syntax for grouping by multiple fields.
7476

7577
* ``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>``
7979

8080
Notes
8181
=====
8282

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.
8784

8885
Examples
8986
========
9087

9188
Example 1: Basic aggregation without grouping
92-
==============================================
89+
---------------------------------------------
9390

9491
This example calculates the average balance across all accounts.
9592

@@ -104,7 +101,7 @@ PPL query::
104101
+--------------+
105102

106103
Example 2: Group by single field
107-
=================================
104+
--------------------------------
108105

109106
This example calculates the count of accounts grouped by gender.
110107

@@ -120,7 +117,7 @@ PPL query::
120117
+---------+--------+
121118

122119
Example 3: Using over and by for multiple field grouping
123-
========================================================
120+
--------------------------------------------------------
124121

125122
This example shows average balance grouped by both gender and age fields.
126123

@@ -138,7 +135,7 @@ PPL query::
138135
+--------+-----+--------------+
139136

140137
Example 4: Using basic limit functionality
141-
========================================
138+
------------------------------------------
142139

143140
This example limits the results to show only the top 1 age group.
144141

@@ -155,7 +152,7 @@ PPL query::
155152
+--------+-------+---------+
156153

157154
Example 5: Using limit with other parameters
158-
=============================================
155+
--------------------------------------------
159156

160157
This example shows using limit with useother and custom otherstr parameters.
161158

@@ -173,7 +170,7 @@ PPL query::
173170
+-------+--------+--------------+
174171

175172
Example 6: Using span with chart command
176-
=======================================
173+
----------------------------------------
177174

178175
This example demonstrates using span for grouping age ranges.
179176

@@ -189,6 +186,5 @@ PPL query::
189186
+--------------+-----+
190187

191188
Limitations
192-
============
189+
-----------
193190
* Only a single aggregation function is supported per chart command.
194-
* When using both row and column splits, the column split field is converted to string type so that it can be used as column names.

0 commit comments

Comments
 (0)