diff --git a/caravel/data/energy.json.gz b/caravel/data/energy.json.gz index b2f47a148..624d71db6 100644 Binary files a/caravel/data/energy.json.gz and b/caravel/data/energy.json.gz differ diff --git a/caravel/models.py b/caravel/models.py index c0752ff74..b8b550612 100644 --- a/caravel/models.py +++ b/caravel/models.py @@ -3,6 +3,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals +import re import functools import json @@ -54,6 +55,7 @@ from caravel.utils import flasher, MetricPermException, DimSelector config = app.config QueryResult = namedtuple('namedtuple', ['df', 'query', 'duration']) +FillterPattern = re.compile(r'''((?:[^,"']|"[^"]*"|'[^']*')+)''') class JavascriptPostAggregator(Postaggregator): @@ -839,7 +841,8 @@ class SqlaTable(Model, Queryable, AuditMixinNullable): for col, op, eq in filter: col_obj = cols[col] if op in ('in', 'not in'): - values = eq.split(",") + splitted = FillterPattern.split(eq)[1::2] + values = [types.replace("'", '').strip() for types in splitted] cond = col_obj.sqla_col.in_(values) if op == 'not in': cond = ~cond @@ -1597,9 +1600,11 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable): cond = ~(Dimension(col) == eq) elif op in ('in', 'not in'): fields = [] - splitted = eq.split(',') - if len(splitted) > 1: - for s in eq.split(','): + # Distinguish quoted values with regular value types + splitted = FillterPattern.split(eq)[1::2] + values = [types.replace("'", '') for types in splitted] + if len(values) > 1: + for s in values: s = s.strip() fields.append(Dimension(col) == s) cond = Filter(type="or", fields=fields) diff --git a/caravel/templates/caravel/explore.html b/caravel/templates/caravel/explore.html index d12b97c15..be87414c9 100644 --- a/caravel/templates/caravel/explore.html +++ b/caravel/templates/caravel/explore.html @@ -106,8 +106,11 @@