You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2022/06/28 17:23:53 UTC

[superset] 02/19: fix: should raise exception when apply a categorical axis (#20451)

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

michaelsmolina pushed a commit to branch 2.0
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 4e93690e194f3fbf13686e3869af063e1c3abedd
Author: Yongjie Zhao <yo...@gmail.com>
AuthorDate: Tue Jun 21 20:37:51 2022 +0800

    fix: should raise exception when apply a categorical axis (#20451)
    
    (cherry picked from commit 8bbbd6f03fbd7fccf457706d942f114b7abb682d)
---
 superset/common/query_context_processor.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/superset/common/query_context_processor.py b/superset/common/query_context_processor.py
index 003c174c2a..8078868493 100644
--- a/superset/common/query_context_processor.py
+++ b/superset/common/query_context_processor.py
@@ -322,6 +322,16 @@ class QueryContextProcessor:
                 #  multi-dimensional charts
                 granularity = query_object.granularity
                 index = granularity if granularity in df.columns else DTTM_ALIAS
+                if not pd.api.types.is_datetime64_any_dtype(
+                    offset_metrics_df.get(index)
+                ):
+                    raise QueryObjectValidationError(
+                        _(
+                            "A time column must be specified "
+                            "when using a Time Comparison."
+                        )
+                    )
+
                 offset_metrics_df[index] = offset_metrics_df[index] - DateOffset(
                     **normalize_time_delta(offset)
                 )