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

   ### What changes were proposed in this pull request?
   
   This PR adds the Python client operations for listing, creating, loading, 
altering, and dropping Semantic Models:
   
   - `SemanticModelCatalogOperations` issues the schema-scoped 
`/semantic-models` REST calls, converts `SemanticModelChange` instances into 
typed update requests, and returns an immutable `GenericSemanticModel`.
   - `RelationalCatalog` exposes the operations through 
`as_semantic_model_catalog()`. Semantic Models are always managed by Gravitino, 
so this does not depend on the underlying connector.
   - Request and response DTOs for the create, update, and load endpoints.
   - `SemanticModelErrorHandler` maps server error codes onto the Semantic 
Model exceptions.
   
   Server implementation, OpenAPI definitions, and other clients are out of 
scope.
   
   ### Why are the changes needed?
   
   This completes the Python client support for Semantic Models started in 
#12612 and #12613 by wiring the API to the REST endpoints.
   
   Depends on #12612 and #12613 for the client types, and on the server REST 
APIs in #12607 and #12608 at runtime.
   
   Fix: #12614
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `catalog.as_semantic_model_catalog()` now returns working operations on 
relational catalogs, matching the Python example in the design doc:
   
   ```python
   ident = NameIdentifier.of("semantic", "sales_model")
   orders = Dataset("orders", NameIdentifier.of("sales", "mart", "orders"))
   definition = SemanticModelDefinition(datasets=[orders])
   
   created = catalog.as_semantic_model_catalog().create_semantic_model(
       ident, "Governed sales definitions", definition, {}
   )
   ```
   
   ### How was this patch tested?
   
   Added 19 unit tests asserting request paths including URL encoding, exact 
request payloads, response mapping, and error mapping, plus 15 cases in 
`test_error_handler.py`.
   
   ```
   ./gradlew :clients:client-python:test
   ```
   
   The full lifecycle was also verified end to end against a local server built 
from #12628, which carries the server and REST commits this PR depends on. 
Using an Iceberg catalog on an in-memory H2 metastore, 22 checks passed: 
create, load, list, exists, all five alter change types, rename, and drop, 
together with the `SemanticModelAlreadyExistsException`, 
`IllegalSemanticModelException`, and `NoSuchSemanticModelException` mappings. 
Definitions round-tripped losslessly, including nested AI context with 
arbitrary additional properties, custom extensions, multi-dialect expressions, 
Ossie data types, and composite unique keys.
   
   A Python integration test is intentionally left out until #12607 and #12608 
merge, and I am happy to add it in a follow-up once they land.
   


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