This is an automated email from the ASF dual-hosted git repository.
aminghadersohi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 36adf6f18c2 docs(semantic-layers): state the count and value-list
completeness contract (#45903)
36adf6f18c2 is described below
commit 36adf6f18c2341e9c3864114bc6a8ccf0e56f94c
Author: Mike Bridge <[email protected]>
AuthorDate: Fri Nov 13 01:03:08 2026 -0600
docs(semantic-layers): state the count and value-list completeness contract
(#45903)
---
.../src/superset_core/semantic_layers/types.py | 49 ++++++++++++++++++++++
.../src/superset_core/semantic_layers/view.py | 43 ++++++++++++++++++-
2 files changed, 90 insertions(+), 2 deletions(-)
diff --git a/superset-core/src/superset_core/semantic_layers/types.py
b/superset-core/src/superset_core/semantic_layers/types.py
index fddc155c528..f8f171a5911 100644
--- a/superset-core/src/superset_core/semantic_layers/types.py
+++ b/superset-core/src/superset_core/semantic_layers/types.py
@@ -364,6 +364,37 @@ class SemanticResult:
This includes any requests (SQL queries, HTTP requests) that were
performed in order
to obtain the results, in order to help troubleshooting.
+
+ **Count results.** A row count is one row with one integer column named
+ ``rowcount``, holding the size of the requested result window (see
+ :class:`SemanticQuery`). The host preserves the provider's column name;
+ Superset's table consumers read ``data[0].rowcount``, so a different name
+ does not supply their pagination total. An empty window is the cell ``0``:
+ not an empty table, ``None`` or a missing column. A count that cannot be
+ established exactly is an error
+ (``superset_core.semantic_layers.errors.SemanticResultCompletenessError``,
+ as incomplete or unverified), never an estimate, the length of a fetched
+ page or a zero standing in for "unknown".
+
+ **Value lists.** A distinct-value result has one column, named after the
+ dimension. ``SemanticView.get_values`` must return the complete matching
+ distinct domain or raise ``SemanticResultCompletenessError``. Consumers
+ may rely on that complete-or-raise contract when the call succeeds; this
+ result type carries no separate completeness-evidence field. A provider
+ must raise if its own page size, transport cap or other ceiling may have
+ omitted matching values.
+
+ ``get_values`` takes no limit. The host obtains the complete filtered set,
+ sorts it and then applies its suggestion limit. For a positive limit, a
+ successful host list shorter than it is the complete matching set; an empty
+ one then means no value matches. A list exactly as long as the limit may
+ have been cut and does not prove that more values exist. Providers must
not silently
+ return a bounded subset through ``get_values``; a bounded suggestion API
+ with different completeness semantics is not defined by this signature.
+
+ These guarantees belong to one observation. A count and a page fetched
+ separately may see different source states; nothing here promises a
snapshot
+ across requests, and ordering is not isolation.
"""
requests: list[SemanticRequest]
@@ -397,6 +428,24 @@ class SemanticQuery:
selected, and may then return rows in any order. ``get_row_count`` gets no
default, since order cannot change a count.
+ **What a count counts.** The *matching result* of a query is its rows at
+ the requested grain after ``filters``, grouping and ``group_limit``, before
+ ``order``, ``offset`` and ``limit``. The *requested result window* is that
+ result, ordered, with ``offset`` rows skipped and at most ``limit`` rows
+ kept. A row count is the number of rows in the requested result window. For
+ a matching result of 123 rows: no limit and no offset counts 123;
+ ``limit=50`` counts 50; ``limit=50, offset=100`` counts 23; ``limit=50,
+ offset=150`` counts 0. ``limit=None`` means no limit and an absent or ``0``
+ ``offset`` means no offset, so a query with neither counts its whole
+ matching result; that unrestricted total is the count of no other query.
+ Rows are rows of the result, never underlying facts or metric values:
+ 10,000 facts that aggregate to 12 groups count 12. A count validates the
+ same shape ``get_table`` would, the shape being members, ``filters``,
+ ``group_limit``, ``limit`` and ``offset`` but not ``order``, so a query the
+ table would reject, such as an offset on a view without ``ROW_OFFSET``, is
+ rejected by the count as well, and a count is accepted whenever the table
+ query would be; a count never widens what may be asked.
+
``group_limit`` is a separate ranking, with its own metric, direction and
optional filters.
diff --git a/superset-core/src/superset_core/semantic_layers/view.py
b/superset-core/src/superset_core/semantic_layers/view.py
index 6b064428291..e15059e1700 100644
--- a/superset-core/src/superset_core/semantic_layers/view.py
+++ b/superset-core/src/superset_core/semantic_layers/view.py
@@ -69,6 +69,14 @@ class SemanticView(ABC):
before ``offset`` and ``limit``. The host gives an unordered
``get_table``
query that selects a temporal dimension a default chronological order.
See
:class:`~superset_core.semantic_layers.types.SemanticQuery`.
+ - **Counts and value lists.** A row count is the size of the requested
+ result window, after ``offset`` and ``limit``, never the unrestricted
+ total of a windowed query or a count of underlying facts. ``get_values``
+ returns the complete filtered distinct set or raises; the host applies
+ its suggestion limit afterwards. Exactness is never approximated: what
+ cannot be verified raises. See
+ :class:`~superset_core.semantic_layers.types.SemanticQuery` and
+ :class:`~superset_core.semantic_layers.types.SemanticResult`.
Uniqueness works at two levels. In the **catalog**, dimensions are unique
per ``(name, grain)`` -- so several grain variants of one name are expected
@@ -157,6 +165,21 @@ class SemanticView(ABC):
never return a partial result instead.
Do not drop ``filters`` and retry when a filtered request is
incomplete.
+ The result is the whole distinct domain of the dimension under
+ ``filters``, not a provider-limited subset. Consumers may rely on this
+ complete-or-raise contract; no separate evidence field is required.
+ This signature takes no limit. The host sorts the complete result and
+ applies its suggestion limit afterwards, returning values up to that
+ limit. A shorter successful host list is complete under the filters;
+ reaching the limit may mean that the host cut the list.
+
+ A page size, transport cap or hard-coded ceiling of the provider's own
+ is not a bound the caller asked for. If it may have cut the result,
+ raise ``SemanticResultCompletenessError`` rather than returning it.
+ A separate bounded-suggestion API must not be improvised here. Values
+ come in no promised order unless the provider documents one applied
+ to the complete result before any cut.
+
Raise SemanticQueryRejectedError for deliberate input rejection, such
as a
search filter the dimension cannot apply; the host returns it to the
user
as a client error with host-owned guidance. Leave operational and
@@ -187,11 +210,27 @@ class SemanticView(ABC):
"""
Execute a query and return the number of rows the result would have.
+ Count the requested result window: the rows of the filtered, grouped
+ result that remain after ``query.offset`` and ``query.limit``, as
+ :class:`~superset_core.semantic_layers.types.SemanticQuery` defines it,
+ under the same validation of the query's shape, ``order`` aside, that
+ ``get_table`` applies. Return one row with one integer column named
+ ``rowcount`` (see
+ :class:`~superset_core.semantic_layers.types.SemanticResult`); an empty
+ window has ``rowcount`` equal to ``0``. The unrestricted total is the
+ count only of a query with neither limit nor offset; for any other
+ query it may be a different number and must not be returned as the
count.
+ A total may be turned into the window count arithmetically only when it
+ describes exactly this query's
+ matching result, with every filter, grouping and group limit applied.
+
Raise SemanticQueryRejectedError for deliberate input rejection.
Raise
``superset_core.semantic_layers.errors.SemanticResultCompletenessError``
- when the result is incomplete or its completeness cannot be verified;
- never return a partial result instead.
+ (``"incomplete"`` or ``"unverified"``) when the count cannot be
established
+ exactly within the provider's budgets: never an estimate, the length
of a
+ fetched page or a zero standing in for "unknown". Never return a
partial
+ result instead.
"""
@abstractmethod