You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2026/08/14 00:36:53 UTC

(superset) branch fix-explore-data-panel-row-limit-cap created (now 648e6712a90)

This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a change to branch fix-explore-data-panel-row-limit-cap
in repository https://gitbox.apache.org/repos/asf/superset.git


      at 648e6712a90 test(explore): cover samples row limit edge cases

This branch includes the following new commits:

     new 315ab16a31b test(explore): add regression guard for samples row-limit cap
     new eb75ed356a2 fix(explore): honor requested samples row limit up to the validated maximum
     new 648e6712a90 test(explore): cover samples row limit edge cases

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 02/03: fix(explore): honor requested samples row limit up to the validated maximum

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch fix-explore-data-panel-row-limit-cap
in repository https://gitbox.apache.org/repos/asf/superset.git

commit eb75ed356a2c0bb48c0875585a63c70ae103a528
Author: sadpandajoe <jc...@gmail.com>
AuthorDate: Fri Aug 14 00:12:48 2026 +0000

    fix(explore): honor requested samples row limit up to the validated maximum
---
 superset/views/datasource/utils.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/superset/views/datasource/utils.py b/superset/views/datasource/utils.py
index d610397e474..4f86e0d6d1c 100644
--- a/superset/views/datasource/utils.py
+++ b/superset/views/datasource/utils.py
@@ -28,7 +28,11 @@ from superset.common.query_context_factory import QueryContextFactory
 from superset.common.utils.query_cache_manager import QueryCacheManager
 from superset.constants import CacheRegion
 from superset.daos.datasource import DatasourceDAO
-from superset.utils.core import extract_dataframe_dtypes, QueryStatus
+from superset.utils.core import (
+    apply_max_row_limit,
+    extract_dataframe_dtypes,
+    QueryStatus,
+)
 from superset.views.datasource.schemas import SamplesPayloadSchema
 
 if TYPE_CHECKING:
@@ -45,9 +49,11 @@ def get_limit_clause(page: Optional[int], per_page: Optional[int]) -> dict[str,
 
     if isinstance(page, int) and isinstance(per_page, int):
         limit = int(per_page)
-        if limit < 0 or limit > samples_row_limit:
+        if limit < 0:
             # reset limit value if input is invalid
             limit = samples_row_limit
+        elif limit:
+            limit = apply_max_row_limit(limit)
 
         offset = max((int(page) - 1) * limit, 0)
 


(superset) 01/03: test(explore): add regression guard for samples row-limit cap

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch fix-explore-data-panel-row-limit-cap
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 315ab16a31b383a386a133ad73c87e9b6de94763
Author: sadpandajoe <jc...@gmail.com>
AuthorDate: Fri Aug 14 00:01:59 2026 +0000

    test(explore): add regression guard for samples row-limit cap
    
    The Explore Data panel's Samples-tab row-limit selector offers 5k/10k
    options and SamplesRequestSchema accepts per_page up to 10000, but
    get_limit_clause() silently resets any per_page above SAMPLES_ROW_LIMIT
    (default 1000) back down to it. A user who selects 5k/10k therefore
    receives at most 1000 rows with no indication the limit was overridden.
    
    Add a focused unit test asserting get_limit_clause honors a per_page the
    samples endpoint accepts. It fails today (returns 1000) and will pass
    once the samples path stops silently clamping accepted per_page values.
    
    Co-Authored-By: Claude Opus 4.8 <no...@anthropic.com>
---
 tests/unit_tests/views/datasource/utils_test.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/unit_tests/views/datasource/utils_test.py b/tests/unit_tests/views/datasource/utils_test.py
index 4788fea92fa..0b170268ac7 100644
--- a/tests/unit_tests/views/datasource/utils_test.py
+++ b/tests/unit_tests/views/datasource/utils_test.py
@@ -22,6 +22,7 @@ import pytest
 
 from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
 from superset.exceptions import SupersetSecurityException
+from superset.views.datasource.utils import get_limit_clause
 
 
 @patch("superset.views.datasource.utils.get_limit_clause")
@@ -215,3 +216,26 @@ def test_get_samples_count_star_access_denied(mock_get_limit_clause: MagicMock):
         mock_samples_context.raise_for_access.assert_called_once()
         # Verify count context was also checked
         mock_count_context.raise_for_access.assert_called_once()
+
+
+@pytest.mark.parametrize("per_page", [5000, 10000])
+def test_get_limit_clause_honors_per_page_above_samples_row_limit(
+    per_page: int,
+) -> None:
+    """Regression guard: the Explore Data panel "Samples" tab silently caps at
+    ``SAMPLES_ROW_LIMIT`` (config default 1000).
+
+    The samples row-limit dropdown offers 5k/10k options and the samples
+    endpoint's ``SamplesRequestSchema`` accepts ``per_page`` up to 10000, yet
+    ``get_limit_clause`` resets any ``per_page`` above ``SAMPLES_ROW_LIMIT``
+    back down to it. A user who selects 5k/10k therefore silently receives at
+    most 1000 rows, with no signal that the requested limit was overridden.
+
+    The rows a user is allowed to request and the rows actually returned must
+    stay consistent: a ``per_page`` the endpoint accepts must not be silently
+    reduced below the request.
+    """
+    assert get_limit_clause(page=1, per_page=per_page) == {
+        "row_offset": 0,
+        "row_limit": per_page,
+    }


(superset) 03/03: test(explore): cover samples row limit edge cases

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch fix-explore-data-panel-row-limit-cap
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 648e6712a90b12e11ef0a8614758c7f71eba03f1
Author: sadpandajoe <jc...@gmail.com>
AuthorDate: Fri Aug 14 00:23:51 2026 +0000

    test(explore): cover samples row limit edge cases
---
 UPDATING.md                                     |  2 ++
 tests/unit_tests/views/datasource/utils_test.py | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/UPDATING.md b/UPDATING.md
index 64787158583..af7e9d70e86 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -24,6 +24,8 @@ assists people when migrating to a new version.
 
 ## Next
 
+- `SAMPLES_ROW_LIMIT` is now the default for `/datasource/samples` requests without a valid explicit `per_page`, rather than a hard per-request ceiling; explicit limits are honored up to the existing global row-limit ceiling, matching `/chart/data` SAMPLES requests.
+
 ### OAuth2 database callback metrics include their outcome
 
 The unqualified `DatabaseRestApi.oauth2` StatsD counter has been replaced with
diff --git a/tests/unit_tests/views/datasource/utils_test.py b/tests/unit_tests/views/datasource/utils_test.py
index 0b170268ac7..cdb9e558507 100644
--- a/tests/unit_tests/views/datasource/utils_test.py
+++ b/tests/unit_tests/views/datasource/utils_test.py
@@ -239,3 +239,20 @@ def test_get_limit_clause_honors_per_page_above_samples_row_limit(
         "row_offset": 0,
         "row_limit": per_page,
     }
+
+
+@pytest.mark.parametrize(
+    "per_page,expected_row_limit",
+    [
+        (0, 0),
+        (-1, 1000),
+    ],
+)
+def test_get_limit_clause_preserves_zero_and_negative_per_page(
+    per_page: int,
+    expected_row_limit: int,
+) -> None:
+    assert get_limit_clause(page=1, per_page=per_page) == {
+        "row_offset": 0,
+        "row_limit": expected_row_limit,
+    }