You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2020/06/29 06:54:26 UTC
[incubator-superset] branch master updated: fix: make time grain
nullable in chart data endpoint (#10187)
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 26d3472 fix: make time grain nullable in chart data endpoint (#10187)
26d3472 is described below
commit 26d34727d3ceb30a59727819254d45f1c504765e
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Mon Jun 29 09:54:01 2020 +0300
fix: make time grain nullable in chart data endpoint (#10187)
* fix: make time grain nullable
* add test
* lint
---
superset/charts/schemas.py | 2 ++
tests/charts/schema_tests.py | 13 ++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/superset/charts/schemas.py b/superset/charts/schemas.py
index 06dc111..3cd2468 100644
--- a/superset/charts/schemas.py
+++ b/superset/charts/schemas.py
@@ -596,10 +596,12 @@ class ChartDataExtrasSchema(Schema):
),
),
example="P1D",
+ allow_none=True,
)
druid_time_origin = fields.String(
description="Starting point for time grain counting on legacy Druid "
"datasources. Used to change e.g. Monday/Sunday first-day-of-week.",
+ allow_none=True,
)
diff --git a/tests/charts/schema_tests.py b/tests/charts/schema_tests.py
index 5f0ef16..fc51d02 100644
--- a/tests/charts/schema_tests.py
+++ b/tests/charts/schema_tests.py
@@ -14,14 +14,15 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+# isort:skip_file
"""Unit tests for Superset"""
from typing import Any, Dict, Tuple
+from tests.test_app import app
from superset.charts.schemas import ChartDataQueryContextSchema
from superset.common.query_context import QueryContext
from tests.base_tests import SupersetTestCase
from tests.fixtures.query_context import get_query_context
-from tests.test_app import app
def load_query_context(payload: Dict[str, Any]) -> Tuple[QueryContext, Dict[str, Any]]:
@@ -59,3 +60,13 @@ class SchemaTestCase(SupersetTestCase):
query_context, errors = ChartDataQueryContextSchema().load(payload)
self.assertIn("row_limit", errors["queries"][0])
self.assertIn("row_offset", errors["queries"][0])
+
+ def test_query_context_null_timegrain(self):
+ self.login(username="admin")
+ table_name = "birth_names"
+ table = self.get_table_by_name(table_name)
+ payload = get_query_context(table.name, table.id, table.type)
+
+ payload["queries"][0]["extras"]["time_grain_sqla"] = None
+ _, errors = ChartDataQueryContextSchema().load(payload)
+ self.assertEqual(errors, {})