Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove backticks on by field in stats #1728

Merged

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.

Signed-off-by: Joshua Li <joshuali925@gmail.com>
@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 <joshuali925@gmail.com>
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

@@ -282,6 +282,27 @@ public void testStatsCommandWithByClause() {
));
}

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

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
14 of 15 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 16, 2023
Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 7525bb1)
acarbonetto pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jun 22, 2023
Signed-off-by: Joshua Li <joshuali925@gmail.com>
dai-chen pushed a commit that referenced this pull request Jun 26, 2023
Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 7525bb1)

Co-authored-by: Joshua Li <joshuali925@gmail.com>
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.

None yet

4 participants