Skip to content

Conversation

@joshuali925
Copy link
Member

Description

Current behavior:

 ppl 'source=accounts | stats count() by `gender`' | jq '.schema[]'
{
  "name": "count()",
  "type": "integer"
}
{
  "name": "`gender`",
  "type": "string"
}

This PR will change it to

 ppl 'source=accounts | stats count() by `gender`' | jq '.schema[]'
{
  "name": "count()",
  "type": "integer"
}
{
  "name": "gender",
  "type": "string"
}

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

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.

@joshuali925
Copy link
Member Author

joshuali925 commented Jun 8, 2023

@vamsi-amazon is it expected to have output fields in backticks for

stats xxx by `field`

i thought it's a bug but seems tests is expecting fields with backticks?

public void testMetricAvgAggregationCommand() {
JSONObject response =
executeQuery("source=`my_prometheus`.`prometheus_http_requests_total` | stats avg(@value) as `agg` by span(@timestamp, 15s), `handler`, `job`");
verifySchema(response,
schema("agg", "double"),
schema("span(@timestamp,15s)", "timestamp"),
schema("`handler`", "string"),
schema("`job`", "string"));

@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Merging #1728 (2225428) into main (94d5479) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##               main    #1728   +/-   ##
=========================================
  Coverage     97.33%   97.33%           
  Complexity     4408     4408           
=========================================
  Files           388      388           
  Lines         10938    10939    +1     
  Branches        773      773           
=========================================
+ Hits          10647    10648    +1     
  Misses          284      284           
  Partials          7        7           
Flag Coverage Δ
sql-engine 97.33% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...java/org/opensearch/sql/ppl/parser/AstBuilder.java 100.00% <100.00%> (ø)

Signed-off-by: Joshua Li <[email protected]>
Yury-Fridlyand
Yury-Fridlyand previously approved these changes Jun 9, 2023
@joshuali925
Copy link
Member Author

confirmed with vamsi the tests can be changed. BWC is failing, error seems irrelevant to this PR

Execution failed for task ':integ-test:sqlBwcCluster#mixedClusterTask'.
> `cluster{:integ-test:sqlBwcCluster0}` failed to wait for cluster health yellow after 40 SECONDS
    IO error while waiting cluster
    503 Service Unavailable


@Test
public void testStatsCommandWithByClauseInBackticks() {
assertEqual("source=t | stats count(a) by `b` DEDUP_SPLITVALUES=false",
Copy link
Member

@vamsimanohar vamsimanohar Jun 16, 2023

Choose a reason for hiding this comment

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

If the query is
"source = t | stats count(a) by `t.b` "

it would treat t.b as column name.

@joshuali925 joshuali925 merged commit 7525bb1 into opensearch-project:main Jun 16, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 16, 2023
Signed-off-by: Joshua Li <[email protected]>
(cherry picked from commit 7525bb1)
acarbonetto pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jun 22, 2023
dai-chen pushed a commit that referenced this pull request Jun 26, 2023
Signed-off-by: Joshua Li <[email protected]>
(cherry picked from commit 7525bb1)

Co-authored-by: Joshua Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants