FrancescoCastaldi commented on issue #45877:
URL: https://github.com/apache/superset/issues/45877#issuecomment-6524013178
### Root Cause Analysis & Solution
In `superset/common/query_object.py:QueryObject.cache_key`, user cache
partitioning attempts to read `self.datasource.database` to build the
impersonation key.
A `SemanticView` object does not possess a `.database` attribute. This
raises an `AttributeError` that is caught and silenced by an enclosing
`try/except` block. As a result, queries executed against semantic views share
identical cache keys regardless of which user initiates the query, ignoring
`CACHE_QUERY_BY_USER = True`.
#### Solution
1. In `superset/semantic_layers/models.py`, update
`SemanticView.get_extra_cache_keys()` to include `("semantic-user",
identity_digest)` when `is_feature_enabled("CACHE_QUERY_BY_USER")` is enabled
and the user is authenticated.
2. In `superset/common/query_object.py`, provide a fallback assigning
`cache_dict["impersonation_key"] = user.username` when `self.datasource` has no
`database` attribute.
This fix is verified with unit tests and committed to branch
`fix/community-unanswered-issues` (commit `79ff341de2c`) at
https://github.com/FrancescoCastaldi/superset/tree/fix/community-unanswered-issues.
--
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]