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/01/04 19:52:19 UTC
[incubator-superset] 18/22: [fix] Druid IS NULL/IS NOT NULL filters
(#8714)
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch 0.35
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit f416f910c1092858fef7ffdd815c2712a33a3e58
Author: John Bodley <45...@users.noreply.github.com>
AuthorDate: Mon Dec 2 20:38:42 2019 -0800
[fix] Druid IS NULL/IS NOT NULL filters (#8714)
---
superset/connectors/druid/models.py | 4 ++--
tests/druid_func_tests.py | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/superset/connectors/druid/models.py b/superset/connectors/druid/models.py
index 8165351..218fd1c 100644
--- a/superset/connectors/druid/models.py
+++ b/superset/connectors/druid/models.py
@@ -1559,9 +1559,9 @@ class DruidDatasource(Model, BaseDatasource):
alphaNumeric=is_numeric_col,
)
elif op == "IS NULL":
- cond = Dimension(col) is None
+ cond = Filter(dimension=col, value="")
elif op == "IS NOT NULL":
- cond = Dimension(col) is not None
+ cond = ~Filter(dimension=col, value="")
if filters:
filters = Filter(type="and", fields=[cond, filters])
diff --git a/tests/druid_func_tests.py b/tests/druid_func_tests.py
index 3afbfac..601cb99 100644
--- a/tests/druid_func_tests.py
+++ b/tests/druid_func_tests.py
@@ -224,6 +224,32 @@ class DruidFuncTestCase(unittest.TestCase):
@unittest.skipUnless(
SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
)
+ def test_get_filters_is_null_filter(self):
+ filtr = {"col": "A", "op": "IS NULL"}
+ col = DruidColumn(column_name="A")
+ column_dict = {"A": col}
+ res = DruidDatasource.get_filters([filtr], [], column_dict)
+ self.assertEqual("selector", res.filter["filter"]["type"])
+ self.assertEqual("", res.filter["filter"]["value"])
+
+ @unittest.skipUnless(
+ SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
+ )
+ def test_get_filters_is_not_null_filter(self):
+ filtr = {"col": "A", "op": "IS NOT NULL"}
+ col = DruidColumn(column_name="A")
+ column_dict = {"A": col}
+ res = DruidDatasource.get_filters([filtr], [], column_dict)
+ self.assertEqual("not", res.filter["filter"]["type"])
+ self.assertIn("field", res.filter["filter"])
+ self.assertEqual(
+ "selector", res.filter["filter"]["field"].filter["filter"]["type"]
+ )
+ self.assertEqual("", res.filter["filter"]["field"].filter["filter"]["value"])
+
+ @unittest.skipUnless(
+ SupersetTestCase.is_module_installed("pydruid"), "pydruid not installed"
+ )
def test_get_filters_constructs_regex_filter(self):
filtr = {"col": "A", "op": "regex", "val": "[abc]"}
col = DruidColumn(column_name="A")