Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

[PPL] Support expression and boolean operators #518

Merged
merged 17 commits into from Jun 26, 2020

Conversation

chloe-zh
Copy link
Member

@chloe-zh chloe-zh commented Jun 11, 2020

Issue #, if available:

Description of changes:

1. Support Boolean operators

Boolean operators supported in the pull request include:

  • less than (<)
  • less than or equal to (<=)
  • greater than (>)
  • greater than or equal to (>=)
  • not equal to (!=)

Additionally supplemented operators in analyzer:

  • NOT in analyzer
  • XOR in parser and analyzer

2. Corrected column name of nested functions/operators (related: #517)

Example: source=accounts | stats avg(abs(age))
Before: returned column name was in pattern avg(object@#)
After: column name is avg(abs(age))

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@chloe-zh chloe-zh marked this pull request as ready for review June 12, 2020 03:36
@chloe-zh chloe-zh changed the title Support expression and boolean operators [PPL] Support expression and boolean operators Jun 12, 2020
String result =
executeQueryToString(
String.format("source=%s | stats avg(abs(age)*2) as AGE", TEST_INDEX_ACCOUNT));
assertEquals(
Copy link
Contributor

Choose a reason for hiding this comment

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

when should we use plan text comparsion? when shoud with use matchers like verifyColumn?

Copy link
Member Author

Choose a reason for hiding this comment

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

To my understanding, we can use verifyColumn like matchers in most of time, but some cases that some other content other than columns and datarows are also important to veriy, so we can flexibly choose text comparison. For example, to verify the formats, or verify the explain results etc.
As for the case this comment referred to, I would like to verify schema, column names, result set of the aggregation, so I chose to compare text.

@@ -210,8 +260,85 @@ private static FunctionResolver equal() {
);
}

private static Map<FunctionSignature, FunctionBuilder> predicateFunction(
private static FunctionResolver notEqual() {
Copy link
Contributor

Choose a reason for hiding this comment

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

could we define notEqual as the combination of not(equal)

Copy link
Member Author

Choose a reason for hiding this comment

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

I was also thinking about it didn't figure it out yet

@penghuo
Copy link
Contributor

penghuo commented Jun 15, 2020

General suggestion, if the PR related to different issue or subject, we should submit serval small PR accordingly instead of using large PR.

Copy link
Contributor

@penghuo penghuo left a comment

Choose a reason for hiding this comment

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

Thanks for the change.

Copy link
Member

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@chloe-zh chloe-zh merged commit 0fad590 into opendistro-for-elasticsearch:develop Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PPL] Support more readable column name of aggregation with expression as argument
3 participants