- 
                Notifications
    
You must be signed in to change notification settings  - Fork 648
 
Add code samples to comments #7347
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
base: wuandy/PortMoreExpr
Are you sure you want to change the base?
Conversation
          Firebase AI Mock Responses Check 
 | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @wu-hui, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces significant refactoring and expansion to the Firestore Pipeline API. The changes aim to enhance the API's structure, consistency, and extensibility by introducing dedicated options classes for various pipeline stages, renaming existing components for better clarity, and adding new functional capabilities.
Highlights
- API Refactoring and Renaming: Several methods and classes within the Firestore Pipeline API have been renamed for improved clarity and consistency. Examples include 
replacebecomingreplaceWith,convertFrombecomingcreateFrom, andAggregateWithAliasbeing renamed toAliasedAggregate. - Introduction of Dedicated Options Classes: New options classes have been introduced for various pipeline stages, such as 
AggregateOptions,FindNearestOptions,CollectionSourceOptions,CollectionGroupOptions, andUnnestOptions. This provides a more structured and extensible way to configure pipeline operations. - New Functional Capabilities: The API now includes new functions like 
countDistinctwithinAggregateFunctionandstrReversefor string manipulation inExprandFunctions. - API Simplification and Consolidation: Some redundant or less flexible API methods have been removed, such as certain 
FindNearestStage.ofoverloads and theoffsetandselectmethods fromRealtimePipeline. 
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description | 
|---|---|---|
| Code Review | /gemini review | 
Performs a code review for the current pull request in its current state. | 
| Pull Request Summary | /gemini summary | 
Provides a summary of the current pull request in its current state. | 
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. | 
| Help | /gemini help | 
Displays a list of available commands. | 
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
- 
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
 
          
 Generated by 🚫 Danger  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces several significant and beneficial refactorings to the Pipeline API, such as renaming methods for clarity (e.g., replace to replaceWith) and introducing options objects for better extensibility (e.g., FindNearestOptions, AggregateOptions). These changes improve the overall API design and maintainability.
However, the pull request title "Add code samples to comments" is misleading as the core changes are API refactorings, not just comment updates. It would be helpful to update the title to reflect the actual changes.
My review includes a critical issue regarding a potential NullPointerException and a suggestion to improve API consistency.
| ctor public FindNearestOptions(); | ||
| method public com.google.firebase.firestore.pipeline.FindNearestOptions self(com.google.firebase.firestore.pipeline.InternalOptions options); | ||
| method public com.google.firebase.firestore.pipeline.FindNearestOptions withDistanceField(com.google.firebase.firestore.pipeline.Field distanceField); | ||
| method public com.google.firebase.firestore.pipeline.FindNearestOptions? withDistanceField(String? distanceField); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signature for withDistanceField(String? distanceField) allows a nullable String and returns a nullable FindNearestOptions?. This is inconsistent with other builder methods in this class which return non-nullable types.
More critically, the current implementation for this method in stage.kt uses a non-null assertion (!!) on the distanceField parameter without a null check, which will lead to a NullPointerException if null is passed.
// stage.kt
fun withDistanceField(distanceField: String?): FindNearestOptions? {
  return withDistanceField(field(distanceField!!))
}To fix this, the implementation should handle the null case gracefully, and the return type in the API should be non-nullable (FindNearestOptions) for consistency.
    method public com.google.firebase.firestore.pipeline.FindNearestOptions withDistanceField(String? distanceField);
        
          
                firebase-firestore/api.txt
              
                Outdated
          
        
      | method public final com.google.firebase.firestore.pipeline.Expr strReverse(); | ||
| method public static final com.google.firebase.firestore.pipeline.Expr strReverse(com.google.firebase.firestore.pipeline.Expr stringExpression); | ||
| method public static final com.google.firebase.firestore.pipeline.Expr strReverse(String fieldName); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition of strReverse is a good step towards a more explicit API, especially since arrayReverse also exists. However, the API now also contains a reverse method that also operates on strings. This creates redundancy and potential confusion for developers.
To improve API clarity and consistency, consider deprecating the reverse method for strings in favor of strReverse.
          
Coverage Report 1Affected Products
 Test Logs | 
    
          
Size Report 1Affected Products
 Test Logs | 
    
c713424    to
    2851bf4      
    Compare
  
    7918ce5    to
    8eb1f21      
    Compare
  
    | 
           The public api surface has changed for the subproject firebase-firestore: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.  | 
    
8eb1f21    to
    f7956c7      
    Compare
  
    | 
           The public api surface has changed for the subproject firebase-firestore: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.  | 
    
f7956c7    to
    545ac38      
    Compare
  
    2851bf4    to
    07892d9      
    Compare
  
    545ac38    to
    5d55ebc      
    Compare
  
    | 
           The public api surface has changed for the subproject firebase-firestore: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.  | 
    
5d55ebc    to
    f99ae6d      
    Compare
  
    | 
           The public api surface has changed for the subproject firebase-firestore: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.  | 
    
f99ae6d    to
    04b6ee2      
    Compare
  
    2. Updated Null/Nan semantics for online execution 3. Validate for duplicated aliases 4. Add new functions
04b6ee2    to
    a62c01a      
    Compare
  
    | 
           The public api surface has changed for the subproject firebase-firestore: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.  | 
    
    
      
        1 similar comment
      
    
  
    | 
           The public api surface has changed for the subproject firebase-firestore: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.  | 
    
Uh oh!
There was an error while loading. Please reload this page.