Skip to content

Commit bb43e53

Browse files
authored
[Backport 2.19-dev] backport markdown doctest support (#4938)
1 parent c6e8de6 commit bb43e53

150 files changed

Lines changed: 19030 additions & 17651 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Recently we have been actively improving our query engine primarily for better c
8888

8989
## Documentation
9090

91-
Please refer to the [SQL Language Reference Manual](./docs/user/index.rst), [Piped Processing Language (PPL) Reference Manual](./docs/user/ppl/index.rst) and [Technical Documentation](https://opensearch.org/docs/latest/search-plugins/sql/index/) for detailed information on installing and configuring plugin.
91+
Please refer to the [SQL Language Reference Manual](./docs/user/index.rst), [Piped Processing Language (PPL) Reference Manual](./docs/user/ppl/index.md) and [Technical Documentation](https://opensearch.org/docs/latest/search-plugins/sql/index/) for detailed information on installing and configuring plugin.
9292

9393
## Forum
9494

docs/category.json

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,60 @@
44
"user/admin/settings.rst"
55
],
66
"bash_calcite": [
7-
"user/ppl/interfaces/endpoint.rst",
8-
"user/ppl/interfaces/protocol.rst"
7+
"user/ppl/interfaces/endpoint.md",
8+
"user/ppl/interfaces/protocol.md"
9+
],
10+
"ppl_cli_calcite": [
11+
"user/ppl/cmd/ad.md",
12+
"user/ppl/cmd/append.md",
13+
"user/ppl/cmd/bin.md",
14+
"user/ppl/cmd/dedup.md",
15+
"user/ppl/cmd/describe.md",
16+
"user/ppl/cmd/eventstats.md",
17+
"user/ppl/cmd/eval.md",
18+
"user/ppl/cmd/fields.md",
19+
"user/ppl/cmd/fillnull.md",
20+
"user/ppl/cmd/grok.md",
21+
"user/ppl/cmd/head.md",
22+
"user/ppl/cmd/join.md",
23+
"user/ppl/cmd/lookup.md",
24+
"user/ppl/cmd/parse.md",
25+
"user/ppl/cmd/patterns.md",
26+
"user/ppl/cmd/rare.md",
27+
"user/ppl/cmd/regex.md",
28+
"user/ppl/cmd/rename.md",
29+
"user/ppl/cmd/multisearch.md",
30+
"user/ppl/cmd/replace.md",
31+
"user/ppl/cmd/rex.md",
32+
"user/ppl/cmd/search.md",
33+
"user/ppl/cmd/showdatasources.md",
34+
"user/ppl/cmd/sort.md",
35+
"user/ppl/cmd/spath.md",
36+
"user/ppl/cmd/stats.md",
37+
"user/ppl/cmd/streamstats.md",
38+
"user/ppl/cmd/subquery.md",
39+
"user/ppl/cmd/syntax.md",
40+
"user/ppl/cmd/chart.md",
41+
"user/ppl/cmd/timechart.md",
42+
"user/ppl/cmd/top.md",
43+
"user/ppl/cmd/trendline.md",
44+
"user/ppl/cmd/where.md",
45+
"user/ppl/functions/collection.md",
46+
"user/ppl/functions/condition.md",
47+
"user/ppl/functions/conversion.md",
48+
"user/ppl/functions/cryptographic.md",
49+
"user/ppl/functions/datetime.md",
50+
"user/ppl/functions/expressions.md",
51+
"user/ppl/functions/ip.md",
52+
"user/ppl/functions/json.md",
53+
"user/ppl/functions/math.md",
54+
"user/ppl/functions/relevance.md",
55+
"user/ppl/functions/statistical.md",
56+
"user/ppl/functions/string.md",
57+
"user/ppl/functions/system.md",
58+
"user/ppl/general/comments.md",
59+
"user/ppl/general/datatypes.md",
60+
"user/ppl/general/identifiers.md"
961
],
1062
"sql_cli": [
1163
"user/dql/expressions.rst",
@@ -21,57 +73,7 @@
2173
"user/dql/complex.rst",
2274
"user/dql/metadata.rst"
2375
],
24-
"ppl_cli_calcite": [
25-
"user/ppl/cmd/ad.rst",
26-
"user/ppl/cmd/append.rst",
27-
"user/ppl/cmd/bin.rst",
28-
"user/ppl/cmd/dedup.rst",
29-
"user/ppl/cmd/describe.rst",
30-
"user/ppl/cmd/eventstats.rst",
31-
"user/ppl/cmd/eval.rst",
32-
"user/ppl/cmd/fields.rst",
33-
"user/ppl/cmd/fillnull.rst",
34-
"user/ppl/cmd/grok.rst",
35-
"user/ppl/cmd/head.rst",
36-
"user/ppl/cmd/join.rst",
37-
"user/ppl/cmd/lookup.rst",
38-
"user/ppl/cmd/parse.rst",
39-
"user/ppl/cmd/patterns.rst",
40-
"user/ppl/cmd/rare.rst",
41-
"user/ppl/cmd/regex.rst",
42-
"user/ppl/cmd/rename.rst",
43-
"user/ppl/cmd/multisearch.rst",
44-
"user/ppl/cmd/replace.rst",
45-
"user/ppl/cmd/rex.rst",
46-
"user/ppl/cmd/search.rst",
47-
"user/ppl/cmd/showdatasources.rst",
48-
"user/ppl/cmd/sort.rst",
49-
"user/ppl/cmd/spath.rst",
50-
"user/ppl/cmd/stats.rst",
51-
"user/ppl/cmd/streamstats.rst",
52-
"user/ppl/cmd/subquery.rst",
53-
"user/ppl/cmd/syntax.rst",
54-
"user/ppl/cmd/chart.rst",
55-
"user/ppl/cmd/timechart.rst",
56-
"user/ppl/cmd/search.rst",
57-
"user/ppl/functions/statistical.rst",
58-
"user/ppl/cmd/top.rst",
59-
"user/ppl/cmd/trendline.rst",
60-
"user/ppl/cmd/where.rst",
61-
"user/ppl/functions/collection.rst",
62-
"user/ppl/functions/condition.rst",
63-
"user/ppl/functions/datetime.rst",
64-
"user/ppl/functions/expressions.rst",
65-
"user/ppl/functions/ip.rst",
66-
"user/ppl/functions/json.rst",
67-
"user/ppl/functions/math.rst",
68-
"user/ppl/functions/relevance.rst",
69-
"user/ppl/functions/string.rst",
70-
"user/ppl/functions/conversion.rst",
71-
"user/ppl/general/datatypes.rst",
72-
"user/ppl/general/identifiers.rst"
73-
],
7476
"bash_settings": [
75-
"user/ppl/admin/settings.rst"
77+
"user/ppl/admin/settings.md"
7678
]
77-
}
79+
}

docs/dev/intro-v3-engine.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@ Find more details in [V3 Architecture](./intro-v3-architecture.md).
2626

2727
In the initial release of the V3 engine (3.0.0), the main new features focus on enhancing the PPL language while maintaining maximum compatibility with V2 behavior.
2828

29-
* **[Join](../user/ppl/cmd/join.rst) Command**
30-
* **[Lookup](../user/ppl/cmd/lookup.rst) Command**
31-
* **[Subquery](../user/ppl/cmd/subquery.rst) Command**
29+
* **[Join](../user/ppl/cmd/join.md) Command**
30+
* **[Lookup](../user/ppl/cmd/lookup.md) Command**
31+
* **[Subquery](../user/ppl/cmd/subquery.md) Command**
32+
33+
V3 (Calcite integration) engine is enabled by default in 3.3.0.
3234

3335
---
3436
## 3.What are Changed
3537

3638
### 3.1 Breaking Changes
3739

38-
Because of implementation changed internally, following behaviors are changed from 3.0.0-beta. (Behaviors in V3 is correct)
40+
Because of implementation changed internally, following behaviors are changed from 3.0.0. (Behaviors in V3 is correct)
3941

4042
| Item | V2 | V3 |
4143
|:------------------------------------------------:|:---------:|:--------------------:|
@@ -56,6 +58,13 @@ Because of implementation changed internally, following behaviors are changed fr
5658

5759
### 3.3 Limitations
5860

61+
For the following commands or functions, we add some defensive restrictions to ensure security.
62+
63+
#### New Restrictions
64+
- `EVAL` won't allow to use [Metadata Fields of OpenSearch](https://docs.opensearch.org/docs/latest/field-types/metadata-fields/index/) as the fields
65+
- `RENAME` won't allow renaming to a [Metadata Fields of OpenSearch](https://docs.opensearch.org/docs/latest/field-types/metadata-fields/index/)
66+
- `as` won't allow to use [Metadata Fields of OpenSearch](https://docs.opensearch.org/docs/latest/field-types/metadata-fields/index/) as the alias name
67+
5968
For the following functionalities in V3 engine, the query will be forwarded to the V2 query engine and thus you cannot use new features in [2. What's New](#2-whats-new).
6069

6170
#### Unsupported functionalities (up to latest)
@@ -80,7 +89,5 @@ If you're interested in the new query engine, please find more details in [V3 Ar
8089
The following items are on our roadmap with high priority:
8190
- Resolve the [V3 limitation](#33-limitations).
8291
- Advancing pushdown optimization and benchmarking
83-
- Backport to 2.19.x
8492
- Unified the PPL syntax between [PPL-on-OpenSearch](https://github.com/opensearch-project/sql/blob/main/ppl/src/main/antlr/OpenSearchPPLParser.g4) and [PPL-on-Spark](https://github.com/opensearch-project/opensearch-spark/blob/main/ppl-spark-integration/src/main/antlr4/OpenSearchPPLParser.g4)
8593
- Support more DSL aggregation
86-

docs/dev/ppl-commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ If you are working on contributing a new PPL command, please read this guide and
5454
- Add a test in `CrossClusterSearchIT`
5555

5656
- [ ] **User doc:**
57-
- Add a xxx.rst under `docs/user/ppl/cmd` and link the new doc to `docs/user/ppl/index.rst`
57+
- Add a xxx.md under `docs/user/ppl/cmd` and link the new doc to `docs/user/ppl/index.md`

docs/dev/testing-doctest.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,58 @@ Doctest runs with project build by `./gradlew build`. You can also only run doct
5757
Make sure you don't have any OpenSearch instance running at `http://localhost:9200`
5858

5959
### 1.4.2 How to write documentation with doctest?
60+
61+
#### RST Format (SQL docs only. On Deprecation path. Use markdown for PPL)
6062
1. If you want to add a new doc, you can add it to `docs` folder, under correct sub-folder, in `.rst` format.
6163
> **Attention**: For code examples in documentation, a Mixing usage of `cli` and `bash` in one doc is not supported yet.
6264
2. Add your new doc file path to `docs/category.json` by its category
6365
3. Run doctest `./gradlew doctest` (optionally with `-DignorePrometheus`) to see if your tests can pass
6466

67+
#### Markdown Format (New - Currently for docs/user/ppl only)
68+
For PPL documentation, Markdown format is now supported with the following guidelines:
69+
70+
1. **File Format**: Create `.md` file(s) in `docs/user/ppl` folder
71+
2. **Category Configuration**: Add markdown files to markdown-only categories in `docs/category.json`:
72+
- `ppl_cli_calcite`: PPL CLI examples with Calcite engine
73+
- `bash_calcite`: Bash/curl examples with Calcite engine
74+
- `bash_settings`: Bash examples for settings/configuration
75+
76+
3. **Code Block Format**: Use **paired** fenced code blocks - each input block must be followed by its expected output block:
77+
78+
```ppl
79+
search source=accounts | where age > 25 | fields firstname, lastname
80+
```
81+
82+
Expected output:
83+
84+
```text
85+
+-------------+------------+
86+
| firstname | lastname |
87+
|-------------+------------|
88+
| Amber | Duke |
89+
| Hattie | Bond |
90+
+-------------+------------+
91+
```
92+
93+
**Input/Output Pairs**: Each input code fence must be immediately followed by an "Expected output:" section with an output code fence
94+
- **Supported Input Languages**: `sql`, `ppl`, `bash`, `sh`, `bash ppl`
95+
- **Supported Output Languages**: `text`, `console`, `output`, `json`, `yaml`
96+
97+
4. **Ignoring Tests**: To skip specific code blocks from testing, add `ignore` attribute:
98+
99+
```ppl ignore
100+
search source=accounts | head 5
101+
```
102+
103+
Expected output:
104+
105+
```text
106+
This output won't be tested
107+
```
108+
109+
5. **Validation**: Markdown categories only accept `.md` files - mixing with `.rst` files will cause validation errors
110+
6. **Testing**: Run `./gradlew doctest` to validate your markdown documentation
111+
65112
Currently, there is a `sample` folder under `docs` module to help you get started.
66113

67114
## 1.5 Future Plan

0 commit comments

Comments
 (0)