Query your data using familiar SQL or intuitive Piped Processing Language (PPL) https://opensearch.org/docs/latest/search-plugins/sql/index/
Find a file
ritvibhatt 8eaa27667c
feat: Implement PPL convert command with 5 conversion functions (#5157)
* feat: Implement PPL convert command with 5 conversion functions

- Added convert command syntax and AST nodes (Convert, ConvertFunction)
- Implemented 5 conversion functions: auto, num, rmcomma, rmunit, none
- Full Calcite pushdown support via CalciteRelNodeVisitor
- Logical and physical operators (LogicalConvert, ConvertOperator)
- Comprehensive test coverage (26 tests total):
  * 13 unit tests (CalcitePPLConvertTest)
  * 8 integration tests with pushdown (ConvertCommandIT)
  * 8 non-pushdown tests (CalciteConvertCommandIT)
  * 3 explain tests (ExplainIT)
  * 2 cross-cluster tests (CrossClusterSearchIT)
  * Anonymizer and v2 unsupported tests
- User documentation (docs/user/ppl/cmd/convert.md)
- Code cleanup: removed dead code, simplified javadocs
- Version: 3.5 (experimental)

All tests compile and pass successfully.

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Fixing integration tests

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Fixing ymal files for IT explain tests

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Fix cross-cluster IT failure

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Making code more readable and removing unnecessary logic

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Refactor: Extract BaseConversionUDF to eliminate duplication

Centralized common conversion function logic into BaseConversionUDF base class,
reducing code from 219 to 162 lines (26% reduction) while maintaining all functionality.

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Fixing CI failure and refactoring

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* trigger CI

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Addressing CodeRabbit comments

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Adding support for memk function

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Fixing formatting

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Updating documentation

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Refactoring code to avoid regestering none() as a convert function and separating concerns into each respective function class

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* refactor: Simplify Convert command using Let expressions

Replace ConvertFunction class with standard Let expressions to
handle none() at AST level and reduce code complexity.

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Trigger CI

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Refactoring code to use Template Method Design Pattern

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Updating documentation

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Trigger CI

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Updating convert example with stats

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Renaming unit test class, as ConversionUtil class was removed

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Fixing IT test case

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Resolve merge conflict: Add testTransposeCommand alongside testConvertCommand

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Add null and empty string tests for NumConvertFunction

Add testNumConvertNullAndEmpty() to ensure NumConvertFunction.convert()
properly returns null for null, empty string, and whitespace-only inputs,
matching the coverage pattern of other conversion functions.

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Add null and empty string tests for RmunitConvertFunction

Add testRmunitConvertNullAndEmpty() to ensure RmunitConvertFunction.convert()
properly returns null for null, empty string, and whitespace-only inputs,
completing the test coverage pattern across all conversion functions.

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Verify convert AS clause preserves original field

Update testConvertWithAlias to verify that using AS clause preserves
the original field alongside the converted field. Test now checks both
balance (bigint) and balance_num (double) are present in results.

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Adding edge test cases, as recommended by Coderabbit

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Trigger CI

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Removing timeformat parameter for now, will add later

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Trigger CI

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* Re-trigger CI

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>

* fix merge conflicts

Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>

* fix cross cluster tests

Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>

* fix merge conflict

Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>

* fix merge conflicts

Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>

* use singleton for udf instance

Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>

---------

Signed-off-by: Aaron Alvarez <aaarone@amazon.com>
Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>
Signed-off-by: ritvibhatt <53196324+ritvibhatt@users.noreply.github.com>
Co-authored-by: Aaron Alvarez <aaarone@amazon.com>
2026-03-06 09:10:30 -08:00
.github Onboard code diff analyzer and reviewer (sql) (#5183) 2026-02-25 15:27:39 -05:00
api Add micro benchmarks for unified query layer (#5043) 2026-01-21 11:50:58 -08:00
async-query Remove all AccessController refs (#4924) 2025-12-10 09:11:58 -08:00
async-query-core bump antlr version to 4.13.2 (#5159) 2026-02-21 01:28:09 -08:00
benchmarks Add micro benchmarks for unified query layer (#5043) 2026-01-21 11:50:58 -08:00
build-tools Integ Test Refactoring (#1383) (#1393) 2023-03-07 14:59:04 -08:00
buildSrc Integ Test Refactoring (#1383) (#1393) 2023-03-07 14:59:04 -08:00
common bump antlr version to 4.13.2 (#5159) 2026-02-21 01:28:09 -08:00
core feat: Implement PPL convert command with 5 conversion functions (#5157) 2026-03-06 09:10:30 -08:00
datasources [Maintenance] Fix bc-fips jar hell by marking dependency as compileOnly (#5158) 2026-02-20 11:11:37 -08:00
direct-query Remove all AccessController refs (#4924) 2025-12-10 09:11:58 -08:00
direct-query-core Fix issue connecting with prometheus by wrapping with AccessController.doPrivilegedChecked (#5061) 2026-02-02 13:23:39 -08:00
docs feat: Implement PPL convert command with 5 conversion functions (#5157) 2026-03-06 09:10:30 -08:00
doctest Add auto-extract mode for spath command (#5140) 2026-02-13 13:30:56 -08:00
gradle/wrapper [3.4.0] Bump Gradle to 9.2.0 and GitHub Action JDK to 25 (#4824) 2025-11-20 14:48:18 +08:00
integ-test feat: Implement PPL convert command with 5 conversion functions (#5157) 2026-03-06 09:10:30 -08:00
language-grammar Revert "Update grammar files and developer guide (#4301)" (#4643) 2025-10-23 10:55:54 -07:00
legacy bump antlr version to 4.13.2 (#5159) 2026-02-21 01:28:09 -08:00
opensearch [Feature] Support bi-directional graph traversal command graphlookup (#5138) 2026-02-25 12:01:55 +08:00
plugin Support fetch_size API for PPL (#5109) 2026-02-04 15:58:50 -08:00
ppl feat: Implement PPL convert command with 5 conversion functions (#5157) 2026-03-06 09:10:30 -08:00
prometheus Remove all AccessController refs (#4924) 2025-12-10 09:11:58 -08:00
protocol Separate explain mode from format params (#5042) 2026-01-14 16:37:34 +08:00
release-notes [CVE-2026-24400] Upgrade assertj-core to 3.27.7 (#5100) 2026-02-03 14:13:27 +08:00
scripts Make sql plugin aware of FIPS build param (-Pcrypto.standard=FIPS-140-3) (#5155) 2026-02-18 16:35:14 -05:00
spark [v3.0.0] Remove SparkSQL support (#3306) 2025-02-10 09:29:52 -08:00
sql bump antlr version to 4.13.2 (#5159) 2026-02-21 01:28:09 -08:00
.codecov.yml Merge develop into main (#142) 2021-06-25 17:47:21 -07:00
.gitignore Fix gitignore to ignore symbolic link (#4263) 2025-09-10 09:26:03 -07:00
.pre-commit-config.yaml Spotless precommit: apply instead of check (#4320) 2025-09-17 16:22:08 -07:00
.whitesource Add .whitesource configuration file 2022-01-05 18:26:14 +00:00
ADMINS.md Merge develop into main (#142) 2021-06-25 17:47:21 -07:00
build.gradle Increment version to 3.6.0-SNAPSHOT (#5115) 2026-02-12 09:44:44 -08:00
CODE_OF_CONDUCT.md OpenSearch Readiness: SQL/PPL, JDBC, ODBC (#8) 2021-04-16 22:08:52 -07:00
CONTRIBUTING.md Bumps version to 1.2 (#254) 2021-11-04 16:12:35 -07:00
CONTRIBUTORS.md Adding our awesome contributors (#463) 2020-05-11 12:53:40 -07:00
DEVELOPER_GUIDE.rst Migrate PPL Documentation from RST to Markdown (#4912) 2025-12-09 13:52:42 -08:00
gradle.properties Mitigate the CI failure caused by 500 Internal Server Error (#4646) 2025-10-24 12:31:37 +08:00
gradlew [3.4.0] Bump Gradle to 9.2.0 and GitHub Action JDK to 25 (#4824) 2025-11-20 14:48:18 +08:00
gradlew.bat [3.4.0] Bump Gradle to 9.2.0 and GitHub Action JDK to 25 (#4824) 2025-11-20 14:48:18 +08:00
LICENSE.txt OpenSearch Readiness: SQL/PPL, JDBC, ODBC (#8) 2021-04-16 22:08:52 -07:00
lombok.config Change the default response format to JDBC. (#334) 2020-01-06 09:01:33 -08:00
MAINTAINERS.md Add Ryan as a maintainer (#4257) 2025-09-17 12:39:01 -04:00
NOTICE Add patterns and grok command (#813) 2022-09-30 09:41:52 -07:00
README.md Migrate PPL Documentation from RST to Markdown (#4912) 2025-12-09 13:52:42 -08:00
RELEASING.md Merge develop into main (#142) 2021-06-25 17:47:21 -07:00
SECURITY.md Updating security reachout email (#2671) 2024-05-14 10:06:47 -07:00
settings.gradle Publish internal modules separately for downstream reuse (#4484) 2025-10-23 16:27:40 -07:00
THIRD-PARTY Improve Syntax Check by New ANTLR Parser (#179) 2019-09-19 13:17:16 -07:00

OpenSearch SQL

OpenSearch enables you to extract insights out of OpenSearch using the familiar SQL or Piped Processing Language (PPL) query syntax. Use aggregations, group by, and where clauses to investigate your data. Read your data as JSON documents or CSV tables so you have the flexibility to use the format that works best for you.

The following projects are related to the SQL plugin, but stored in the different repos. Please refer to links below for details. This document will focus on the SQL plugin for OpenSearch.

Code Summary

SQL Engine

Test and build [![SQL CI][sql-ci-badge]][sql-ci-link]
Code coverage codecov
Distribution build tests OpenSearch IT tests OpenSearch IT code
Backward compatibility tests BWC tests

Repository Checks

DCO Checker Developer certificate of origin
Link Checker Link Checker

Issues

good first issues open
features open
enhancements open
bugs open
untriaged open
nolabel open

Highlights

Besides basic filtering and aggregation, OpenSearch SQL also supports complex queries, such as querying semi-structured data, JOINs, set operations, sub-queries etc. Beyond the standard functions, OpenSearch functions are provided for better analytics and visualization. Please check our documentation for more details.

Recently we have been actively improving our query engine primarily for better correctness and extensibility. Behind the scene, the new enhanced engine has already supported both SQL and Piped Processing Language. Please find more details in SQL Engine V2 - Release Notes.

Documentation

Please refer to the SQL Language Reference Manual, Piped Processing Language (PPL) Reference Manual, OpenSearch SQL/PPL Engine Development Manual and Technical Documentation for detailed information on installing and configuring plugin.

Forum

For additional help with the plugin, including questions about opening an issue, visit the OpenSearch Forum.

Contributing

See developer guide and how to contribute to this project.

Attribution

This project is based on the Apache 2.0-licensed elasticsearch-sql project. Thank you eliranmoyal, shi-yuan, ansjsun and everyone else who contributed great code to that project. Read this for more details Attributions.

Code of Conduct

This project has adopted an Open Source Code of Conduct.

Security

If you discover a potential security issue in this project we ask that you notify OpenSearch Security directly via email to security@opensearch.org. Please do not create a public GitHub issue.

License

See the LICENSE file for our project's licensing. We will ask you to confirm the licensing of your contribution.

Copyright OpenSearch Contributors. See NOTICE for details.