Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Regression in support of sort in queries [DATACASS-842] #1008

Closed
spring-projects-issues opened this issue Dec 31, 2020 · 3 comments
Closed
Assignees
Labels
type: regression A regression from a previous release

Comments

@spring-projects-issues
Copy link

Luc Boutier opened DATACASS-842 and commented

When migrating a project from cassandra 2.x to 3.x I encountered an issue in the ordering of sort parameters.
The clustering key of my object contains (in order) fields repairOrderId and revisionId and I was using the following query

val query = query(where("partitionKey").is(partitionKey)).sort(by(DESC, "repairOrderId", "revisionId"))
return cassandraTemplate.selectOne(query, RepairOrderByBasket::class.java)

It seems that somehow the sort is mixing up and creates a statement with 

ORDER BY revisionId DESC, repairOrderId DESC

that cassandra does not support (it requires the same order as clustering keys so 

ORDER BY repairOrderId DESC, revisionId DESC

In my particular case it was actually just better to use a clustering ordering on the table definition rather than at the query level but I guess this can be an issue in some other context


No further details from DATACASS-842

@spring-projects-issues spring-projects-issues added the type: bug A general bug label Dec 31, 2020
@mp911de mp911de added type: regression A regression from a previous release and removed type: bug A general bug labels Jan 29, 2021
@mp911de
Copy link
Member

mp911de commented Jan 29, 2021

Thanks for the report @lucboutier. That's caused by collecting sort orders in a Map which messes up the actual order of sort-by properties.

@mp911de mp911de added this to the 3.0.7 (Neumann SR7) milestone Jan 29, 2021
mp911de added a commit that referenced this issue Jan 29, 2021
Replace stream() usage with for-loops where possible to reduce GC overhead.

See #1008.
mp911de added a commit that referenced this issue Jan 29, 2021
We now apply sort-by properties individually on the built statement instead of collecting these into a Map first.

Resolves #1008
mp911de added a commit that referenced this issue Jan 29, 2021
Replace stream() usage with for-loops where possible to reduce GC overhead.

See #1008.
mp911de added a commit that referenced this issue Jan 29, 2021
We now apply sort-by properties individually on the built statement instead of collecting these into a Map first.

Resolves #1008
@mp911de
Copy link
Member

mp911de commented Jan 29, 2021

That's fixed now.

mp911de added a commit that referenced this issue Jan 29, 2021
Replace stream() usage with for-loops where possible to reduce GC overhead.

See #1008.
@lucboutier
Copy link

Amazing! Thanks a lot for the great work!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

3 participants