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 Unimplemented PPL Sort Syntax #994

Merged
merged 12 commits into from
Jan 9, 2025

Conversation

currantw
Copy link
Contributor

@currantw currantw commented Dec 16, 2024

Description

Updates documentation to mark PPL sort syntax (e.g. sort num) as unimplemented.
Temporary measure related to #963, where the consensus seems to be that this syntax should eventually be supported.

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
@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
Contributor 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
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.

@YANG-DB YANG-DB added Lang:PPL Pipe Processing Language support 0.7 labels Dec 19, 2024
@currantw
Copy link
Contributor Author

currantw commented Jan 3, 2025

Based on the conversation here, it seems like consensus is that we should implement the PPL sort syntax, rather than deprecate and remove it. As such, I have changed this PR to simply mark it as "unimplemented" so that users don't unwittingly use it.

@@ -122,41 +123,47 @@ class PPLLogicalPlanParseTranslatorTestSuite

test("test parse email & host expressions including cast and sort commands") {
Copy link
Member

@YANG-DB YANG-DB Jan 4, 2025

Choose a reason for hiding this comment

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

@currantw plz add the corresponding IT (place holder ?) for a concrete index:

    val query =
      "source=t" +
        " | parse address '(?<streetNumber>\\d+) (?<street>.+)'" +
        " | eval streetNumberInt = cast(streetNumber as integer)" +
        " | where streetNumberInt > 500" +
        " | sort streetNumberInt" +
        " | fields streetNumber, street"

@currantw currantw changed the title #963 Deprecate Unimplemented PPL Sort Syntax #963 Unimplemented PPL Sort Syntax Jan 6, 2025
@YANG-DB
Copy link
Member

YANG-DB commented Jan 6, 2025

@currantw LGTM ...

@@ -274,7 +274,8 @@ source = table | where ispresent(a) |
- `source=accounts | parse email '.+@(?<host>.+)' | stats count() by host`
- `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`
- `source=accounts | parse address '(?<streetNumber>\d+) (?<street>.+)' | eval streetNumberInt = cast(streetNumber as integer) | where streetNumberInt > 500 | sort streetNumberInt | fields streetNumber, street`
- **Note**: The `sort num` syntax is not implemented. 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.

Suggested change
- **Note**: The `sort num` syntax is not implemented. 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.
- **Note**: The `sort num` syntax is not implemented. See [#963](https://github.com/opensearch-project/opensearch-spark/issues/963) for more details.

@@ -68,6 +68,8 @@ PPL query:
| 880 | Holmes Lane |
+----------------+----------------+

**Note**: The `sort num` syntax is not implemented. 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.

Someone in the future may get confused by this comment since the sort num syntax is no longer mentioned here.
I'd suggest removing the node completely.

@YANG-DB
Copy link
Member

YANG-DB commented Jan 6, 2025

@currantw plz check why build is failing

Signed-off-by: currantw <[email protected]>
@YANG-DB YANG-DB merged commit 6610253 into opensearch-project:main Jan 9, 2025
4 checks passed
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.

4 participants