PiotrAndrzejewsky opened a new pull request, #14746:
URL: https://github.com/apache/gravitino/pull/14746

   ### What changes were proposed in this pull request?
   
   - Add `supports_credentials()` and `supports_secrets()` to `Catalog` 
interface (`gravitino.api.catalog.Catalog`).
   - Implement `SupportsCredentials` in `RelationalCatalog` 
(`gravitino.client.relational_catalog.RelationalCatalog`), exposing 
`supports_credentials()` and `get_credentials()`.
   - Standardize `supports_credentials()` and `supports_secrets()` on 
`FilesetCatalog` and `RelationalCatalog`, keeping `support_credentials()` and 
`support_secrets()` as aliases for backwards compatibility.
   - Fix `SupportsCredentials.get_credential()` to compare 
`credential.credential_type()` instead of comparing the method reference.
   - Add unit test coverage in `test_credential_api.py`, `test_secret_api.py`, 
and `test_relational_catalog.py`.
   
   ### Why are the changes needed?
   
   In Java, `Catalog` defines `supportsCredentials()` and `supportsSecrets()`, 
and `RelationalCatalog` implements both interfaces. In Python:
   1. `Catalog` was missing `supports_credentials()` and `supports_secrets()`.
   2. `RelationalCatalog` did not implement `SupportsCredentials` (even though 
`_object_credential_operations` was already initialized in `BaseSchemaCatalog`).
   3. Methods were named in the singular (`support_credentials` / 
`support_secrets`), which was inconsistent with `supports_tags`, 
`supports_policies`, `supports_roles`, and the Java API.
   4. **Bug fix in `SupportsCredentials.get_credential()`**:
          The `Credential` abstract base class defines `credential_type(self) ->
          str` as a method (not a `@property`). 
          In `SupportsCredentials.get_credential()`, line 72 previously checked 
          `if credential.credential_type == credential_type`. 
          Because `credential.credential_type` was evaluated without      
          parentheses, Python compared a bound method object (`<bound method 
          Credential.credential_type of ...>`) to the `str` type identifier     
          (e.g. `"s3-token"`). This comparison always evaluated to `False`, 
          causing `get_credential()` to invariably raise
          `NoSuchCredentialException` for any valid credential type. 
          This PR fixes it by calling `credential.credential_type()` with     
          defensive attribute handling. 
   
   
   Fix: #14742
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes:
   - `catalog.supports_credentials()` and `catalog.supports_secrets()` are now 
available on `Catalog`.
   - `relational_catalog.supports_credentials()` is now available to obtain 
credentials on relational catalogs.
   - Existing methods `support_credentials()` and `support_secrets()` are 
preserved as backward-compatible aliases.
   
   ### How was this patch tested?
   
   - Added unit tests in:
     - `clients/client-python/tests/unittests/test_credential_api.py`
     - `clients/client-python/tests/unittests/test_secret_api.py`
     - `clients/client-python/tests/unittests/test_relational_catalog.py`
   - Python unit tests: 1438/1438 passed (`./gradlew 
:clients:client-python:test --max-workers=4`)
   - Python integration tests: 505/505 passed (`./gradlew 
:clients:client-python:integrationTest --max-workers=4`)


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