You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/06/08 09:30:10 UTC

[GitHub] [incubator-superset] dpgaspar commented on a change in pull request #10010: feat: add support for query offset

dpgaspar commented on a change in pull request #10010:
URL: https://github.com/apache/incubator-superset/pull/10010#discussion_r436566726



##########
File path: superset/charts/schemas.py
##########
@@ -664,6 +664,7 @@ class ChartDataQueryObjectSchema(Schema):
     row_limit = fields.Integer(
         description='Maximum row count. Default: `config["ROW_LIMIT"]`',
     )
+    row_offset = fields.Integer(description="Number of rows to skip. Default: `0`",)

Review comment:
       consider enforcing `row_offset` is >0
   ```
   validate=[Range(min=0, error=_("row_offset must be greater than 0"))])
   ```
   

##########
File path: superset/charts/schemas.py
##########
@@ -664,6 +664,7 @@ class ChartDataQueryObjectSchema(Schema):
     row_limit = fields.Integer(

Review comment:
       consider enforcing `row_limit` is >0
   ```
   validate=[Range(min=0, error=_("row_limit must be greater than 0"))])
   ```
   

##########
File path: tests/charts/api_tests.py
##########
@@ -634,19 +636,43 @@ def test_get_charts_no_data_access(self):
         data = json.loads(rv.data.decode("utf-8"))
         self.assertEqual(data["count"], 0)
 
-    def test_chart_data(self):
+    def test_chart_data_simple(self):
         """
         Query API: Test chart data query
         """
         self.login(username="admin")
         table = self.get_table_by_name("birth_names")
-        payload = get_query_context(table.name, table.id, table.type)
-        uri = "api/v1/chart/data"
-        rv = self.post_assert_metric(uri, payload, "data")
+        request_payload = get_query_context(table.name, table.id, table.type)
+        rv = self.post_assert_metric(CHART_DATA_URI, request_payload, "data")
         self.assertEqual(rv.status_code, 200)
         data = json.loads(rv.data.decode("utf-8"))
         self.assertEqual(data["result"][0]["rowcount"], 100)
 
+    def test_chart_data_limit_offset(self):
+        """
+        Query API: Test chart data query with limit and offset
+        """
+        self.login(username="admin")
+        table = self.get_table_by_name("birth_names")
+        request_payload = get_query_context(table.name, table.id, table.type)
+        request_payload["queries"][0]["row_limit"] = 5

Review comment:
       Would be nice to a couple of simple tests with invalid `row_limit` and `row_offset`. negative values, bigger then `SAMPLES_ROW_LIMIT`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org