Skip to content

feat: add projection and map support for aggregations (#539) #629

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 1 commit into from
Jul 31, 2025

Conversation

bsbodden
Copy link
Collaborator

Implements Spring Data-style projections and map-based results for aggregations, providing flexible alternatives to tuple-based results. Follows Spring Data conventions where IDs are not automatically included in projections.

  • Add toProjection(Class

    ) method for interface-based projections

  • Add toMaps() and toMaps(boolean includeId) for map-based results
  • Projections follow Spring Data JPA pattern (IDs not auto-included)
  • Maps include IDs by default with option to exclude
  • Dynamic proxy implementation for projection interfaces
  • Type conversion support for common types
  • Comprehensive tests for both document and hash entities
  • Documentation with examples and comparison of approaches

@bsbodden bsbodden requested a review from Copilot July 31, 2025 18:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements Spring Data-style projections and map-based results for aggregations, providing flexible alternatives to tuple-based results. It follows Spring Data conventions where IDs are not automatically included in projections.

  • Adds interface-based projection support via toProjection(Class<P>) method with dynamic proxy implementation
  • Adds map-based results with toMaps() and toMaps(boolean includeId) methods for flexible data access
  • Provides comprehensive documentation with examples showing different approaches (projections vs maps vs tuples)

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
AggregationStreamImpl.java Core implementation adding projection and map methods with dynamic proxy creation and type conversion
AggregationStream.java Interface definitions for the new toProjection and toMaps methods
AggregationProjectionTest.java Comprehensive test suite for projection functionality with document entities
AggregationHashProjectionTest.java Test suite ensuring projection features work with hash entities
Documentation files Updated documentation with examples and guidance on using projections and maps

Implements Spring Data-style projections and map-based results for aggregations,
providing flexible alternatives to tuple-based results. Follows Spring Data
conventions where IDs are not automatically included in projections.

- Add toProjection(Class<P>) method for interface-based projections
- Add toMaps() and toMaps(boolean includeId) for map-based results
- Projections follow Spring Data JPA pattern (IDs not auto-included)
- Maps include IDs by default with option to exclude
- Dynamic proxy implementation for projection interfaces
- Type conversion support for common types
- Comprehensive tests for both document and hash entities
- Documentation with examples and comparison of approaches
@bsbodden bsbodden merged commit 9c63e8e into redis:main Jul 31, 2025
1 check passed
@bsbodden bsbodden deleted the bsb/issue-539 branch July 31, 2025 20:10
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.

1 participant