-
Notifications
You must be signed in to change notification settings - Fork 33
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
#963 Deprecate Unimplemented PPL Sort Syntax #994
base: main
Are you sure you want to change the base?
Conversation
b44dad7
to
0e03dd8
Compare
: (PLUS | MINUS)? sortFieldExpression | ||
; | ||
|
||
sortFieldExpression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@currantw if i understand correctly - we remove the cast capability in the sort statement in favour of using the cast
operator before ...
- can u plz add a few additional test examples for these use cases ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the discussion on the corresponding SQL issue, it seems like the consensus is to just mark as deprecated right now. I've updated this PR as suggested, so I think this comment is resolved for the time being. I've added a comment on the issue above with some example of equivalent sort
commands using cast
.
I don't think the sort syntax is |
Thanks @LantaoJin. Agree that "unimplemented" is more accurate. Please also see the discussion on the equivalent SQL issue. The consensus there seems to be to keep this syntax for the time being, update all the documentation to indicate that this syntax is deprecated, and remove it completely in the next major release. As such, I will be updating this PR to merely mark the syntax as deprecated. |
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
473f0c3
to
a5f35bc
Compare
Signed-off-by: currantw <[email protected]>
@@ -263,7 +262,6 @@ public UnresolvedExpression visitCaseExpr(OpenSearchPPLParser.CaseExprContext ct | |||
public UnresolvedExpression visitIsEmptyExpression(OpenSearchPPLParser.IsEmptyExpressionContext ctx) { | |||
Function trimFunction = new Function(TRIM.getName().getFunctionName(), Collections.singletonList(this.visitFunctionArg(ctx.functionArg()))); | |||
Function lengthFunction = new Function(LENGTH.getName().getFunctionName(), Collections.singletonList(trimFunction)); | |||
Compare lengthEqualsZero = new Compare(EQUAL.getName().getFunctionName(), lengthFunction, new Literal(0, DataType.INTEGER)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this removed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly good - just one question about this part:
Compare lengthEqualsZero = new Compare(EQUAL.getName().getFunctionName(), lengthFunction, new Literal(0, DataType.INTEGER));
This doesn't resolve #963 - but just deprecates the unimplemented language. |
@@ -68,6 +68,8 @@ PPL query: | |||
| 880 | Holmes Lane | | |||
+----------------+----------------+ | |||
|
|||
**Note**: The `sort num` syntax is deprecated. To sort numerically, cast to a numerical data type - e.g. `sort cast(streetNumber as integer)`. See [#963](https://github.com/opensearch-project/opensearch-spark/issues/963) for more details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update the example above to use the cast syntax instead?
@@ -275,6 +275,7 @@ source = table | where ispresent(a) | | |||
- `source=accounts | parse email '.+@(?<host>.+)' | eval eval_result=1 | fields host, eval_result` | |||
- `source=accounts | parse email '.+@(?<host>.+)' | where age > 45 | sort - age | fields age, email, host` | |||
- `source=accounts | parse address '(?<streetNumber>\d+) (?<street>.+)' | where streetNumber > 500 | sort num(streetNumber) | fields streetNumber, street` | |||
- **Note**: The `sort num` syntax is deprecated. To sort numerically, cast to a numerical data type - e.g. `sort cast(streetNumber as integer)`. See [#963](https://github.com/opensearch-project/opensearch-spark/issues/963) for more details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update the example above to use the cast syntax instead?
@@ -80,7 +77,7 @@ public class AstExpressionBuilder extends OpenSearchPPLParserBaseVisitor<Unresol | |||
.put("isnotnull", IS_NOT_NULL.getName().getFunctionName()) | |||
.put("ispresent", IS_NOT_NULL.getName().getFunctionName()) | |||
.build(); | |||
private AstBuilder astBuilder; | |||
private final AstBuilder astBuilder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes in this file seem like merge conflicts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@currantw I agree with @acarbonetto - can we only keep changes relevant for this PR ?
thanks
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Description
Resolves #963.
Related Issues
OpenSearch SQL issue: opensearch-project/sql#3180
Check List
Updated documentation (docs/ppl-lang/README.md)New added source code should include a copyright header--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.