dengc367 commented on issue #14308:
URL: https://github.com/apache/gravitino/issues/14308#issuecomment-6515432159
Adding the two flows as sequence diagrams, to make the responsibility split
easier to see.
**Today** - steps 2-3 run in the planner service, so every other consumer of
the model has to duplicate them:
```mermaid
sequenceDiagram
participant U as Agent
participant P as Planner service
participant C as Catalog (Gravitino / Unity Catalog)
participant E as Engine (Spark / Trino)
U->>P: 1. semantic query {metrics, dimensions, filters, limit}
activate P
P->>C: 2. read current model definition
C-->>P: datasets, relationships, per-dialect expressions
Note over P: 3. resolve on the client side<br/>metric to owning dataset
+ expression<br/>dimension to field<br/>shortest join path
(INNER)<br/>aggregate vs group-by
Note over P: 4. render dialect SQL<br/>aliases, quoting, literal syntax
P->>E: 5. execute SQL
E-->>P: rows
P-->>U: rows
deactivate P
Note over U,E: 6. Authorization holds only if the caller identity is
forwarded on step 2,<br/>otherwise the planner service's own privileges
apply.<br/>Steps 2-3 are the model knowledge every consumer
duplicates.<br/>Steps 4-5 stay with the planner service after the change.
```
**After** - step 3 moves next to the model, step 4 shrinks to a converter,
and step 5 onwards is untouched:
```mermaid
sequenceDiagram
participant U as Agent
participant P as Planner service
participant G as Gravitino (semantic model + authz)
participant E as Engine (Spark / Trino)
U->>P: 1. semantic query {metrics, dimensions, filters, limit}
activate P
P->>G: 2. POST .../semantic-models/{model}/plan
Note over G: 3. resolve once, on the server<br/>metric to owning dataset
+ expression<br/>shortest join path (INNER)<br/>aggregate classification +
groupBy<br/>authorize USE_SEMANTIC_MODEL<br/>record semanticModelVersion
G-->>P: dialect-neutral plan<br/>sources, joins, selections, filters,
groupBy, limit, version
Note over P: 4. converter only<br/>pick the dialect expression, assign
aliases,<br/>quote identifiers, render literals, assemble the statement
P->>E: 5. execute SQL (or build a LogicalPlan)
E-->>P: rows
P-->>U: rows
deactivate P
Note over U,E: Resolution and authorization happen once, next to the
model.<br/>The planner service keeps rendering, optimization, execution and
caching.
```
Read across: the request shape (1) and the execution path (5+) are
identical. What changes is who resolves (3) and how much rendering is left (4).
The planner service keeps rendering, optimization, execution and caching, so
this is not "move the planner into Gravitino" - it is "stop every consumer from
re-deriving the same model knowledge".
--
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]