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

#963 Deprecate Unimplemented PPL Sort Syntax #994

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

currantw
Copy link

Description

Resolves #963.

Related Issues

OpenSearch SQL issue: opensearch-project/sql#3180

Check List

  • Updated documentation (docs/ppl-lang/README.md)
  • Implemented unit tests
  • Implemented tests for combination with other commands
  • New added source code should include a copyright header
  • 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.

@currantw currantw force-pushed the #963_ppl_sort_syntax branch from b44dad7 to 0e03dd8 Compare December 16, 2024 16:53
: (PLUS | MINUS)? sortFieldExpression
;

sortFieldExpression
Copy link
Member

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 ?

Copy link
Author

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.

@LantaoJin
Copy link
Member

LantaoJin commented Dec 19, 2024

I don't think the sort syntax is outdated. But I agree we should remove this syntax since it is unimplemented. How about change the PR title to Remove unimplemented PPL Sort Syntax?

@currantw
Copy link
Author

currantw commented Dec 19, 2024

I don't think the sort syntax is outdated. But I agree we should remove this syntax since it is unimplemented. How about change the PR title to Remove unimplemented PPL Sort Syntax?

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.

@currantw currantw changed the title #963 Remove Outdated PPL Sort Syntax #963 Deprecate Unimplemented PPL Sort Syntax Dec 19, 2024
@currantw currantw force-pushed the #963_ppl_sort_syntax branch from 473f0c3 to a5f35bc Compare December 19, 2024 16:34
@@ -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));
Copy link
Member

Choose a reason for hiding this comment

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

why was this removed ?

Copy link
Author

Choose a reason for hiding this comment

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

Unused variable.

Copy link
Member

@YANG-DB YANG-DB left a 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));

@acarbonetto
Copy link

This doesn't resolve #963 - but just deprecates the unimplemented language.
I would link the issues together, but I don't think we should close that issue just because we're deprecating the 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.

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.

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;

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?

Copy link
Member

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

@YANG-DB YANG-DB added Lang:PPL Pipe Processing Language support 0.7 labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.7 Lang:PPL Pipe Processing Language support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Unimplemented PPL Sort Syntax
4 participants