Skip to content

Implement string expressions #1036

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

Merged
merged 2 commits into from
Nov 15, 2022
Merged

Implement string expressions #1036

merged 2 commits into from
Nov 15, 2022

Conversation

katcharov
Copy link
Collaborator

JAVA-4801

Implements string expressions from the top 50, and a few others.

See: https://www.mongodb.com/docs/manual/reference/operator/aggregation/#string-expression-operators

@katcharov katcharov force-pushed the expressions-comparison branch from e4a6e00 to 5f07226 Compare November 9, 2022 15:43
@katcharov katcharov requested review from jyemin and stIncMale November 9, 2022 18:59
Base automatically changed from expressions-comparison to expressions November 10, 2022 19:18

StringExpression toUpper();

StringExpression concat(StringExpression concat);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This appends the string to the current string. Should we have a prepend method? If so, should this method be renamed?

Copy link
Member

@stIncMale stIncMale Nov 10, 2022

Choose a reason for hiding this comment

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

When a question is posed this way, it forces others to think about it from scratch, then describe pros/cons, potential usages, and suggest a decision. I think that all of this work should be done by the one who asks the question so that others could analyze the proposed options and express their opinion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here is an example where prepend (first line) is much easier to naturally write, compared to the equivalent append:

[a, b, c, d].map(v -> v.toString().trim().first(3).prepend(">"))
[a, b, c, d].map(v -> of(">").append(v.toString().trim().first(3)))

We discussed this and are leaning towards using prepend/append here, though the reductive operation would be concat (see #1032 (comment) ). Additional input welcome.

@katcharov katcharov mentioned this pull request Nov 14, 2022
@rozza rozza removed their request for review November 15, 2022 14:31
@katcharov katcharov merged commit 93355a1 into expressions Nov 15, 2022
@katcharov katcharov deleted the expressions-string branch November 15, 2022 16:44
katcharov added a commit that referenced this pull request Jan 30, 2023
katcharov added a commit that referenced this pull request Jan 31, 2023
katcharov added a commit that referenced this pull request Jan 31, 2023
* Implement boolean expressions (#1025)

JAVA-4779

* Implement filter, map, reduce (#1031)

JAVA-4781

* Implement eq, ne, gt, gte, lt, lte (#1033)

JAVA-4784

* Implement string expressions (#1036)

JAVA-4801

* Implement arithmetic expressions (#1037)

Implement arithmetic expressions (from top 50, and others)

JAVA-4803

* Implement array expressions (#1043)

JAVA-4805

* Implement date expressions (#1045)

JAVA-4804

* Implement conversion/type expressions (#1050)

JAVA-4802

* Implement document expressions (#1052)

JAVA-4782

* Replace reduce with individual reductions (#1053)

JAVA-4814

* Implement map expressions (#1054)

JAVA-4817

* Implement switch expression (#1055)

JAVA-4813

* Test expressions in context (#1057)

JAVA-4820

* Add javadoc for boolean, date, number, integer, and expression (#1059)

 JAVA-4799

* Update and add documentation (#1059)

* Fix, tests

 JAVA-4799

* Add `@MqlUnchecked` and a few usage examples (#1059)

 JAVA-4799

* Add has to document, add tests (#1070)

 JAVA-4799

* Add javadocs for remaining classes (#1070)

 JAVA-4799

* 5.2 annotations (#1070)

 JAVA-4799

* 5.0 annotations (#1070)

 JAVA-4799

* 4.4 annotations (#1070)

 JAVA-4799

* 4.2 annotations (#1070)

 JAVA-4799

* 4.0 annotations (#1070)

 JAVA-4799

* Update and add documentation, add tests, fix minor issues (#1070)

Rename extractBsonValue

Fix access modifiers

Remove excess comments

Update docs

Fix: behaviour of get

Add notNull to API, add notNullApi test

Fix docs/annotations, tests

Fix docs, annotations, since

Fix docs

Revert external

Add missing MqlUnchecked

Fix missing null checks

Checkstyle

JAVA-4799

* Rename to Mql (automated) (#1073)

JAVA-3879

* Rename methods (automated) (#1073)

JAVA-3879

* Update naming, terms, and missing checks and annotations (#1073)

JAVA-3879

---------

Co-authored-by: Valentin Kovalenko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants