Skip to content

Conversation

@penghuo
Copy link
Collaborator

@penghuo penghuo commented Oct 6, 2025

Description

  • Add the YAML explain format responses. It more human readable.
  • Refresh user documentation. Example 4 YAML format (experimental). Marked it as experimental, the reasons is YAML format is more for developer to debug and test. The response may change.
calcite:
  logical: |
    LogicalSystemLimit(fetch=[10000], type=[QUERY_SIZE_LIMIT])
      LogicalProject(name=[$0], country=[$1], state=[$2], month=[$3], year=[$4], age=[$5])
        LogicalFilter(condition=[>($5, 30)])
          CalciteLogicalIndexScan(table=[[OpenSearch, state_country]])
  physical: |
    CalciteEnumerableIndexScan(table=[[OpenSearch, state_country]], PushDownContext=[[PROJECT->[name, country, state, month, year, age], FILTER->>($5, 30), LIMIT->10000], OpenSearchRequestBuilder(sourceBuilder={"from":0,"size":10000,"timeout":"1m","query":{"range":{"age":{"from":30,"to":null,"include_lower":false,"include_upper":true,"boost":1.0}}},"_source":{"includes":["name","country","state","month","year","age"],"excludes":[]}}, requestedTotalSize=10000, pageSize=null, startFrom=0)])

Related Issues

#4351

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

import org.opensearch.sql.storage.TableScanOperator;

/** OpenSearch execution engine implementation. */
public class OpenSearchExecutionEngine implements ExecutionEngine {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): Should we move the explain functionality to a dedicated location?

The class is somewhat large as-is, and I don't like the idea of adding more complexity to OpenSearchExecutionEngine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

I like your PR. add yaml format to minic that.

Signed-off-by: Peng Huo <[email protected]>
"user/admin/settings.rst"
],
"ppl_cli": [
"bash_calcite": [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test PPL with calcite

-----------------------------------

The following PPL query demonstrated that where and stats command were pushed down to OpenSearch DSL aggregation query::
Explain query::
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refresh doctest will correct response. Not breaking change.

assertYamlEqualsIgnoreId(
expected,
explainQueryToString(
explainQueryYaml(
Copy link
Collaborator Author

@penghuo penghuo Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leverage Yaml response format.
Deprecated assertYamlEqualsJsonIgnoreId function. @ykmr1224 Please take a look

Comment on lines 46 to 48
builder.put(STANDARD.formatName, STANDARD);
builder.put(EXTENDED.formatName, EXTENDED);
builder.put(COST.formatName, COST);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These not response FORMAT. We should deprecated these in 4.0 and suggest user using explain statement

Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
Signed-off-by: Peng Huo <[email protected]>
@penghuo penghuo marked this pull request as draft October 11, 2025 00:45
Signed-off-by: Peng Huo <[email protected]>
@penghuo penghuo marked this pull request as ready for review October 11, 2025 02:41
@penghuo penghuo merged commit d6a9719 into opensearch-project:main Oct 20, 2025
33 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.19-dev failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.19-dev 2.19-dev
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.19-dev
# Create a new branch
git switch --create backport/backport-4446-to-2.19-dev
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 d6a9719f3c8d73f1b274842c5b83e7df7df5d9ca
# Push it to GitHub
git push --set-upstream origin backport/backport-4446-to-2.19-dev
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.19-dev

Then, create a pull request where the base branch is 2.19-dev and the compare/head branch is backport/backport-4446-to-2.19-dev.

@RyanL1997
Copy link
Collaborator

may need to manual backport it

penghuo added a commit to penghuo/os-sql that referenced this pull request Oct 20, 2025
@penghuo
Copy link
Collaborator Author

penghuo commented Oct 20, 2025

Manual backport #4609

penghuo added a commit to penghuo/os-sql that referenced this pull request Oct 22, 2025
@LantaoJin LantaoJin added the backport-manually Filed a PR to backport manually. label Oct 22, 2025
penghuo added a commit that referenced this pull request Oct 22, 2025
* Support format=yaml in Explain API (#4446)

---------

Signed-off-by: Peng Huo <[email protected]>

* Fix compile issue in main (#4608)

Signed-off-by: Peng Huo <[email protected]>

* Update

Signed-off-by: Peng Huo <[email protected]>

* update doc

Signed-off-by: Peng Huo <[email protected]>

* Update

Signed-off-by: Peng Huo <[email protected]>

---------

Signed-off-by: Peng Huo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 2.19-dev backport-failed backport-manually Filed a PR to backport manually. enhancement New feature or request PPL Piped processing language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants