codeant-ai-for-open-source[bot] commented on code in PR #45395:
URL: https://github.com/apache/superset/pull/45395#discussion_r4330706493
##########
superset-core/src/superset_core/semantic_layers/testing.py:
##########
@@ -59,3 +78,250 @@ def semantic_layer_registration(monkeypatch:
pytest.MonkeyPatch) -> None:
integration lane. Use in isolated provider test processes, not a live host.
"""
monkeypatch.setattr(decorators, "semantic_layer", _registration)
+
+
+# Keep test data and provider construction in the provider's own fixtures. This
+# suite consumes the real SDK types rather than a copy of a factory signature.
+class SemanticProviderConformance:
+ """Subclass in a ``Test...`` class and supply the documented provider
fixtures.
+
+ Query fixtures seed discriminating data and provide independent expected
+ Arrow tables for identity, grain, NULL, grouped OR, and order-before-limit.
+ Error fixtures call real provider methods against controlled backend
outcomes.
+ See the provider author guide for every fixture and the limits of this
suite.
+ """
+
+ def test_catalog_identity(
+ self, semantic_view: SemanticView, semantic_reloaded_view: SemanticView
+ ) -> None:
+ """Stable selections survive reloads without ambiguous catalog
members."""
+ assert semantic_view.uid()
+ assert semantic_view.uid() == semantic_reloaded_view.uid()
+ assert _catalog(semantic_view) == _catalog(semantic_reloaded_view)
+
+ @pytest.mark.parametrize(
+ "case", ["identity", "grain", "null", "not_null", "or", "order_limit"]
+ )
+ def test_query_outputs(
+ self,
+ case: str,
+ semantic_view: SemanticView,
+ semantic_query_cases: Mapping[str, tuple[SemanticQuery, pa.Table]],
+ ) -> None:
+ """Compare executed results, including column names and row order."""
+ query: SemanticQuery
+ expected: pa.Table
+ query, expected = semantic_query_cases[case]
+ assert expected.num_rows > 0, (
+ f"{case} must distinguish a correct result from no data"
+ )
+ assert query.order or expected.num_rows == 1, (
+ f"{case}: multi-row fixtures need explicit order"
+ )
+ assert set(query.dimensions) <= semantic_view.get_dimensions()
+ assert set(query.metrics) <= semantic_view.get_metrics()
+ if case == "grain":
+ assert any(dimension.grain is not None for dimension in
query.dimensions)
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> For semantic-query grain tests, verify grain selection by comparing the
query result with an expected fixture that distinguishes the grain; do not
require every provider to expose multiple grain variants.
**Applied to:**
- `**/test/**`
- `**/tests/**`
- `**/*test*.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
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]