bito-code-review[bot] commented on code in PR #44835:
URL: https://github.com/apache/superset/pull/44835#discussion_r4159640713
##########
superset/semantic_layers/models.py:
##########
@@ -257,9 +259,18 @@ def after_delete(
security_manager.semantic_layer_after_delete(mapper, connection,
target)
- @cached_property
+ @property
def implementation(
self,
+ ) -> SemanticLayerABC[Any, SemanticViewABC]:
+ if metadata_binding.participates(self):
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Repeated config JSON parse per property access</b></div>
<div id="fix">
`implementation` changed from `cached_property` to a property that re-runs
`metadata_binding.participates` — a `json.loads(self.configuration)` plus
registry lookup — on every access; `get_extra_cache_keys` triggers at least two
such parses per query cache-key computation. `SemanticView.implementation`
(line 371) repeats the pattern. Consider caching the parse per operation.
</div>
</div>
<small><i>Code Review Run #1752a8</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset/semantic_layers/models.py:
##########
@@ -700,7 +718,18 @@ def data_for_slices(self, slices: list[Any]) ->
ExplorableData:
return self.data
def get_extra_cache_keys(self, query_obj: QueryObjectDict) ->
list[Hashable]:
- return []
+ token: str | None = self.metadata_cache_token
+ return [token] if token is not None else []
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Unhandled MetadataRefreshError in cache-key path</b></div>
<div id="fix">
`get_extra_cache_keys` now propagates `MetadataRefreshError` (raised by
`metadata_cache_token` via `metadata_binding.view_implementation`/`_operation`
when no operation budget exists, or by `connection_store` when
`DISTRIBUTED_COORDINATION_CONFIG` is missing) into `query_cache_key`
(`query_context_processor.py:431`), which has no handler; chart queries fail at
cache-key computation. Consider translating the error here.
</div>
</div>
<small><i>Code Review Run #1752a8</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]