diff --git a/bijoe/engine.py b/bijoe/engine.py index b44bd8c..3a4d862 100644 --- a/bijoe/engine.py +++ b/bijoe/engine.py @@ -259,8 +259,13 @@ class EngineCube(object): json_key = name[5:] return schemas.Join( name=name, - table='(SELECT DISTINCT %s.%s->>\'%s\' AS value FROM %s ORDER BY value)' % ( - self.fact_table, self.json_field, json_key, self.fact_table), + table=( + '(SELECT DISTINCT %s.%s->>\'%s\' AS value FROM %s ' + 'WHERE %s.%s->>\'%s\' IS NOT NULL ORDER BY value)' % ( + self.fact_table, self.json_field, json_key, self.fact_table, + self.fact_table, self.json_field, json_key + ) + ), master='%s->>\'%s\'' % (self.json_field, json_key), detail='value', )