sql icon indicating copy to clipboard operation
sql copied to clipboard

Make explain of ProjectOperator with alias show both name and alias info

Open qianheng-aws opened this issue 6 months ago • 1 comments

Description

Add name information as well in the explain of ProjectOperator with alias, so user can identify whether the field in his plan comes from the right source.

POST _plugins/_sql/_explain
{
  "query": "SELECT (FlightTimeMin + 1) as FlightTimeMinPlusOne FROM opensearch_dashboards_sample_data_flights LIMIT 5"
}


#Before this PR
{
  "root": {
    "name": "ProjectOperator",
    "description": {
      "fields": "[FlightTimeMinPlusOne]"
    },
    "children": [
      {
        "name": "OpenSearchIndexScan",
        "description": {
          "request": """OpenSearchQueryRequest(indexName=opensearch_dashboards_sample_data_flights, sourceBuilder={"from":0,"size":5,"timeout":"1m","_source":{"includes":["FlightTimeMin"],"excludes":[]}}, searchDone=false)"""
        },
        "children": []
      }
    ]
  }
}

#With this PR
{
  "root": {
    "name": "ProjectOperator",
    "description": {
      "fields": "[(FlightTimeMin + 1) AS FlightTimeMinPlusOne]"
    },
    "children": [
      {
        "name": "OpenSearchIndexScan",
        "description": {
          "request": """OpenSearchQueryRequest(indexName=opensearch_dashboards_sample_data_flights, sourceBuilder={"from":0,"size":5,"timeout":"1m","_source":{"includes":["FlightTimeMin"],"excludes":[]}}, searchDone=false)"""
        },
        "children": []
      }
    ]
  }
}

Related Issues

Resolves #2901

Check List

  • [x] New functionality includes testing.
  • [ ] New functionality has been documented.
  • [ ] New functionality has javadoc added.
  • [ ] New functionality has a user manual doc added.
  • [ ] API changes companion pull request created.
  • [x] Commits are signed per the DCO using --signoff.
  • [ ] 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.

qianheng-aws avatar Aug 07 '24 04:08 qianheng-aws