khawaja-abdullah opened a new pull request, #8421:
URL: https://github.com/apache/gravitino/pull/8421

   <!--
   1. Title: [#<issue>] <type>(<scope>): <subject>
      Examples:
        - "[#123] feat(operator): support xxx"
        - "[#233] fix: check null before access result in xxx"
        - "[MINOR] refactor: fix typo in variable name"
        - "[MINOR] docs: fix typo in README"
        - "[#255] test: fix flaky test NameOfTheTest"
      Reference: https://www.conventionalcommits.org/en/v1.0.0/
   2. If the PR is unfinished, please mark this PR as draft.
   -->
   
   ### What changes were proposed in this pull request?
   In `GroupMetaH2Provider.listExtendedGroupPOsByMetalakeId`, both `roleNames` 
and `roleIds` now use:
   
   - Added a `CASE` expression inside `GROUP_CONCAT` to filter out `NULL` and 
empty strings, ensuring only valid role values are included i.e. not mapped to 
`""`
   - Used `COALESCE(GROUP_CONCAT(...), '')` to guarantee the aggregate never 
evaluates to `NULL`
   - Prevented the previous behavior where no roles resulted in `[""]`, by 
ensuring that when no valid entries exist the result becomes `[]`.  
   - Preserved correct quoting of non-empty values (`"value"`) for 
compatibility with JSON parsing expectations.  
   
   This guarantees clean JSON-like array strings.
   
   ### Why are the changes needed?
   
   Previously, if no roles existed, the query returned `[""]`, which 
misrepresents the absence of roles.  
   With this fix, such cases now correctly return `[]`.  
   This improves correctness and avoids downstream parsing issues.
   
   Fix: #8408 
   
   ### Does this PR introduce _any_ user-facing change?
   Yes.  
   - **Before:** empty roles → `[""]`  
   - **After:** empty roles → `[]`  
   - Non-empty cases remain unchanged (e.g. `["Admin","User"]`). 
   
   ### How was this patch tested?
   - Verified with H2:
     - Groups with multiple roles → quoted list.  
     - Groups with only empty/NULL roles → values skipped.  
     - Groups with no roles → `[]`.  
   - Added integration tests to confirm all scenarios.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to