sririshindra opened a new issue, #4674:
URL: https://github.com/apache/polaris/issues/4674

   ## Background
   
   `PolarisEvent.catalogId` is `NOT NULL` in the persistence schema. To 
accommodate
   events that are not catalog-scoped (principal, principal-role, policy, 
credential,
   etc.), PR #4225 introduced a magic string sentinel:
   
   ```java
   public static final String REALM_SCOPED = "__realm__";
   ```
   
   Realm-scoped events store `"__realm__"` in the `catalog_id` column instead of
   `NULL`. This is a transitional placeholder — see the inline `TODO` on
   `PolarisEvent.REALM_SCOPED` ([code reference][code]) and the discussion on
   [#4225 (comment)][r3262281270].
   
   ## Problem
   
   - A reserved string in a name column is collision-prone — a real catalog 
could in
     principle be named `__realm__`.
   - Downstream audit/query tooling must remember to filter the sentinel out 
instead
     of using the natural `WHERE catalog_id IS NULL`.
   - The schema lies about the data model: realm-scoped events conceptually have
     no catalog, but the column claims otherwise.
   
   ## Proposed change
   
   1. Make `catalog_id` nullable in the persistence schema (DDL change + 
migration
      for existing deployments).
   2. Update `PolarisEvent` so `catalogId` is `@Nullable`, drop `REALM_SCOPED`.
   3. Update `PolarisPersistenceEventListener` to pass `null` for 
non-catalog-scoped
      events instead of the sentinel.
   4. Update downstream queries / tests that currently filter on `REALM_SCOPED`.
   5. Provide a one-time backfill (`UPDATE polaris_event SET catalog_id = NULL 
WHERE
      catalog_id = '__realm__'`) in the migration.
   
   ## Affected modules
   
   - `polaris-core` — `PolarisEvent`
   - `runtime/service` — `PolarisPersistenceEventListener`, related tests
   - Persistence implementations (JDBC / relational backends with the events 
table
     schema)
   
   ## Out of scope
   
   - API/event-payload changes — only the storage representation moves.
   - Behavior change for non-realm-scoped events.
   
   ## References
   
   - PR #4225 — introduced the sentinel
   - Review thread: [#4225 (comment)][r3262281270]
   - Resolution comment: [#4225 (comment)][r3359327421]
   
   [code]: 
https://github.com/apache/polaris/blob/main/polaris-core/src/main/java/org/apache/polaris/core/entity/PolarisEvent.java
   [r3262281270]: 
https://github.com/apache/polaris/pull/4225#discussion_r3262281270
   [r3359327421]: 
https://github.com/apache/polaris/pull/4225#discussion_r3359327421


-- 
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