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: DEVELOPER_GUIDE.rst
+40-76Lines changed: 40 additions & 76 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,15 +17,15 @@ Prerequisites
17
17
JDK
18
18
---
19
19
20
-
OpenSearch builds using Java 11 at a minimum and supports JDK 11, 14 and 17. This means you must have a JDK of supported version installed with the environment variable `JAVA_HOME` referencing the path to Java home for your JDK installation::
20
+
OpenSearch SQL plugin requires Java 21 for development and runtime. This means you must have JDK 21 installed with the environment variable `JAVA_HOME` referencing the path to Java home for your JDK installation::
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
26
+
openjdk version "21.0.8" 2024-07-16 LTS
27
+
OpenJDK Runtime Environment (build 21.0.8+13-LTS)
28
+
OpenJDK 64-Bit Server VM (build 21.0.8+13-LTS, mixed mode, sharing)
29
29
30
30
Here are the official instructions on how to set ``JAVA_HOME`` for different platforms: https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/.
31
31
@@ -78,12 +78,12 @@ You can develop the plugin in your favorite IDEs such as Eclipse and IntelliJ ID
78
78
Java Language Level
79
79
-------------------
80
80
81
-
Although later version of JDK is required to build the plugin, the Java language level needs to be Java 8 for compatibility. Only in this case your plugin works with OpenSearch running against JDK 8. Otherwise it will raise runtime exception when executing new API from new JDK. In case your IDE doesn’t set it right, you may want to double check your project setting after import.
81
+
The plugin requires Java 21 for both development and runtime. Make sure your IDE is configured to use Java 21 as the project SDK and language level. In case your IDE doesn't set it right, you may want to double check your project setting after import.
82
82
83
83
Remote Debugging
84
84
----------------
85
85
86
-
Firstly you need to add the following configuration to the JVM used by your IDE. For Intellij IDEA, it should be added to ``<OpenSearch installation>/config/jvm.options`` file. After configuring this, an agent in JVM will listen on the port when your OpenSearch bootstraps and wait for IDE debugger to connect. So you should be able to debug by setting up a “Remote Run/Debug Configuration”::
86
+
Firstly you need to add the following configuration to the JVM used by your IDE. For Intellij IDEA, it should be added to ``<OpenSearch installation>/config/jvm.options`` file. After configuring this, an agent in JVM will listen on the port when your OpenSearch bootstraps and wait for IDE debugger to connect. So you should be able to debug by setting up a "Remote Run/Debug Configuration"::
To connect to the cluster with the debugger in an IDE, you’ll need to
97
+
To connect to the cluster with the debugger in an IDE, you'll need to
98
98
connect to that port. For IntelliJ, see `attaching to a remote process <https://www.jetbrains.com/help/idea/attach-to-process.html#attach-to-remote>`_.
99
99
100
100
License Header
101
101
--------------
102
102
103
-
Because our code is licensed under Apache 2, you need to add the following license header to all new source code files. To automate this whenever creating new file, you can follow instructions for your IDE::
104
-
105
-
/*
106
-
* Licensed under the Apache License, Version 2.0 (the "License").
107
-
* You may not use this file except in compliance with the License.
108
-
* A copy of the License is located at
109
-
*
110
-
* http://www.apache.org/licenses/LICENSE-2.0
111
-
*
112
-
* or in the "license" file accompanying this file. This file is distributed
113
-
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
114
-
* express or implied. See the License for the specific language governing
115
-
* permissions and limitations under the License.
116
-
*/
103
+
Because our code is licensed under Apache 2, you need to add the following license header to all new source code files. To automate this whenever creating new file, you can follow instructions for your IDE.
104
+
105
+
.. code:: java
106
+
107
+
/*
108
+
* Copyright OpenSearch Contributors
109
+
* SPDX-License-Identifier: Apache-2.0
110
+
*/
117
111
118
112
For example, `here are the instructions for adding copyright profiles in IntelliJ IDEA <https://www.jetbrains.com/help/idea/copyright.html>`__.
119
113
@@ -138,10 +132,10 @@ The plugin codebase is in standard layout of Gradle project::
138
132
├── build.gradle
139
133
├── config
140
134
├── docs
141
-
│ ├── attributions.md
142
-
│ ├── category.json
143
-
│ ├── dev
144
-
│ └── user
135
+
│ ├── attributions.md
136
+
│ ├── category.json
137
+
│ ├── dev
138
+
│ └── user
145
139
├── gradle.properties
146
140
├── gradlew
147
141
├── gradlew.bat
@@ -217,63 +211,21 @@ Java files are formatted using `Spotless <https://github.com/diffplug/spotless>`
217
211
* - Javadoc format can be maintained by wrapping javadoc with `<pre></pre>` HTML tags
218
212
* - Strings can be formatted on multiple lines with a `+` with the correct indentation for the string.
219
213
220
-
New PPL Command Checklist
221
-
=========================
214
+
Development Guidelines
215
+
----------------------
222
216
223
-
If you are working on contributing a new PPL command, please read this guide and review all items in the checklist are done before code review. You also can leverage this checklist to guide how to add new PPL command.
217
+
For detailed development documentation, please refer to the `development documentation <docs/dev/index.md>`_. For specific guidance on implementing PPL components, see the following resources:
224
218
225
-
Prerequisite
226
-
------------
227
-
228
-
|✅ Open an RFC issue before starting to code:
229
-
- Describe the purpose of the new command
230
-
- Include at least syntax definition, usage and examples
231
-
- Implementation options are welcome if you have multiple ways to implement it
232
-
|✅ Obtain PM review approval for the RFC:
233
-
- If PM unavailable, consult repository maintainers as alternative
234
-
- An offline meeting might be required to discuss the syntax and usage
235
-
236
-
Coding & Tests
237
-
--------------
238
-
239
-
|✅ Lexer/Parser Updates:
240
-
- Add new keywords to OpenSearchPPLLexer.g4
241
-
- Add grammar rules to OpenSearchPPLParser.g4
242
-
- Update ``commandName`` and ``keywordsCanBeId``
243
-
|✅ AST Implementation:
244
-
- Add new tree nodes under package ``org.opensearch.sql.ast.tree``
245
-
- Prefer reusing ``Argument`` for command arguments **over** creating new expression nodes under ``org.opensearch.sql.ast.expression``
246
-
|✅ Visitor Pattern:
247
-
- Add ``visit*`` in ``AbstractNodeVisitor``
248
-
- Overriding ``visit*`` in ``Analyzer``, ``CalciteRelNodeVisitor`` and ``PPLQueryDataAnonymizer``
249
-
|✅ Unit Tests:
250
-
- Extend ``CalcitePPLAbstractTest``
251
-
- Keep test queries minimal
252
-
- Include ``verifyLogical()`` and ``verifyPPLToSparkSQL()``
253
-
|✅ Integration tests (pushdown):
254
-
- Extend ``PPLIntegTestCase``
255
-
- Use complex real-world queries
256
-
- Include ``verifySchema()`` and ``verifyDataRows()``
257
-
|✅ Integration tests (Non-pushdown):
258
-
- Add test class to ``CalciteNoPushdownIT``
259
-
|✅ Explain tests:
260
-
- Add tests to ``ExplainIT`` or ``CalciteExplainIT``
261
-
|✅ Unsupported in v2 test:
262
-
- Add a test in ``NewAddedCommandsIT``
263
-
|✅ Anonymizer tests:
264
-
- Add a test in ``PPLQueryDataAnonymizerTest``
265
-
|✅ Cross-cluster Tests (optional, nice to have):
266
-
- Add a test in ``CrossClusterSearchIT``
267
-
|✅ User doc:
268
-
- Add a xxx.rst under ``docs/user/ppl/cmd`` and link the new doc to ``docs/user/ppl/index.rst``
219
+
- `PPL Commands <docs/dev/ppl-commands.md>`_: Guidelines for adding new commands to PPL
220
+
- `PPL Functions <docs/dev/ppl-functions.md>`_: Instructions for implementing and integrating custom functions
269
221
270
222
Building and Running Tests
271
223
==========================
272
224
273
225
Gradle Build
274
226
------------
275
227
276
-
Most of the time you just need to run ./gradlew build which will make sure you pass all checks and testing. While you’re developing, you may want to run specific Gradle task only. In this case, you can run ./gradlew with task name which only triggers the task along with those it depends on. Here is a list for common tasks:
228
+
Most of the time you just need to run ./gradlew build which will make sure you pass all checks and testing. While you're developing, you may want to run specific Gradle task only. In this case, you can run ./gradlew with task name which only triggers the task along with those it depends on. Here is a list for common tasks:
277
229
278
230
.. list-table::
279
231
:widths: 30 50
@@ -294,7 +246,7 @@ Most of the time you just need to run ./gradlew build which will make sure you p
294
246
* - ./gradlew :integ-test:yamlRestTest
295
247
- Run rest integration test.
296
248
* - ./gradlew :doctest:doctest
297
-
- Run doctests
249
+
- Run doctests in docs folder. You can use ``-Pdocs=file1,file2`` to run specific file(s). See more info in `Documentation <#documentation>`_ section.
298
250
* - ./gradlew build
299
251
- Build plugin by run all tasks above (this takes time).
300
252
* - ./gradlew pitest
@@ -304,7 +256,7 @@ Most of the time you just need to run ./gradlew build which will make sure you p
For integration test, you can use ``-Dtests.class`` “UT full path” to run a task individually. For example ``./gradlew :integ-test:integTest -Dtests.class="*QueryIT"``.
259
+
For integration test, you can use ``-Dtests.class`` "UT full path" to run a task individually. For example ``./gradlew :integ-test:integTest -Dtests.class="*QueryIT"``.
308
260
309
261
To run the task above for specific module, you can do ``./gradlew :<module_name>:task``. For example, only build core module by ``./gradlew :core:build``.
310
262
@@ -466,6 +418,18 @@ Doctest
466
418
467
419
Python doctest library makes our document executable which keeps it up-to-date to source code. The doc generator aforementioned served as scaffolding and generated many docs in short time. Now the examples inside is changed to doctest gradually. For more details please read `testing-doctest <./docs/dev/testing-doctest.md>`_.
0 commit comments