Skip to content

Support descending queries #3499

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 8 commits into from
Mar 14, 2022
Merged

Support descending queries #3499

merged 8 commits into from
Mar 14, 2022

Conversation

schmidt-sebastian
Copy link
Contributor

I am really struggling to understand why this was broken and not detected by the existing tests. I also wonder whether this is actually the right fix and could use a thorough set of eyes.

I am really struggling to understand why this was broken and not detected by the existing tests. I also wonder whether this is actually the right fix and could use a thorough set of eyes.
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 1, 2022

Coverage Report 1

Affected Products

  • firebase-firestore

    Overall coverage changed from 45.61% (f103c35) to 45.63% (180d45c) by +0.02%.

    FilenameBase (f103c35)Merge (180d45c)Diff
    AsyncQueue.java78.11%77.11%-1.00%
    PatchMutation.java100.00%98.39%-1.61%
    SetMutation.java94.29%97.14%+2.86%
    SQLiteIndexManager.java98.69%99.48%+0.79%
    Target.java95.83%96.02%+0.19%

Test Logs

Notes

  • Commit (180d45c) is created by Prow via merging PR base commit (f103c35) and head commit (487288c).
  • Run gradle <product>:checkCoverage to produce HTML coverage reports locally. After gradle commands finished, report files can be found under <product-build-dir>/reports/jacoco/.

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/FRcg2rA9GJ.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 1, 2022

Size Report 1

Affected Products

  • firebase-firestore

    TypeBase (f103c35)Merge (180d45c)Diff
    aar1.24 MB1.24 MB+444 B (+0.0%)
    apk (release)3.38 MB3.38 MB+148 B (+0.0%)

Test Logs

Notes

  • Commit (180d45c) is created by Prow via merging PR base commit (f103c35) and head commit (487288c).

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/P3OrDozFGE.html

.orderBy(orderBy("c", "desc"))
.orderBy(orderBy("b", "asc"))
.orderBy(orderBy("a", "desc"))
.limitToFirst(2);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove limitToFirst as it's not the intent of the test.

For completion, I'd suggest testing the 4 combinations:

  • c > 2 and c DESC (already covered here)
  • c > 2 and c ASC
  • c < 5 and c ASC
  • c < 5 and c DESC

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we should also add some test cases that have startAt/endAt for each of them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The limitToLast() was there since verifyResults did not validate ordering, and this was a quick hack to ensure that the ordering here worked. I changed the IndexManager API to return an ordered list instead of a Set. This allowed me to remove the limit here and validate the ordering of the result.

if (max(segmentValue, cursorValue) == cursorValue) {
segmentValue = cursorValue;
segmentInclusive = startAt.isInclusive();
if (max(segmentBound.first, cursorValue) == cursorValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

took me a minute to realize why we always do max here, and not decide whether we should do min or max based on the segment kind.
We should add tests that contain startAt and endAt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added tests, which actually showed that this logic is wrong (I compared the result with the Java Server SDK for validation). This is now part of the getAscendingBound() logic.

@schmidt-sebastian
Copy link
Contributor Author

/run binary-size

@ehsannas
Copy link
Contributor

/test smoke-tests

@schmidt-sebastian schmidt-sebastian merged commit 54f6ee7 into master Mar 14, 2022
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/bug branch March 14, 2022 17:19
@google-oss-bot
Copy link
Contributor

@schmidt-sebastian: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
smoke-tests 487288c link /test smoke-tests

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@firebase firebase locked and limited conversation to collaborators Apr 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants