本文整理汇总了Python中superset.connectors.druid.models.DruidDatasource.get_filters方法的典型用法代码示例。如果您正苦于以下问题:Python DruidDatasource.get_filters方法的具体用法?Python DruidDatasource.get_filters怎么用?Python DruidDatasource.get_filters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类superset.connectors.druid.models.DruidDatasource
的用法示例。
在下文中一共展示了DruidDatasource.get_filters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_filters_handles_arrays_for_string_types
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_handles_arrays_for_string_types(self):
filtr = {'col': 'A', 'op': '==', 'val': ['a', 'b']}
res = DruidDatasource.get_filters([filtr], [])
self.assertEqual('a', res.filter['filter']['value'])
filtr = {'col': 'A', 'op': '==', 'val': []}
res = DruidDatasource.get_filters([filtr], [])
self.assertEqual('', res.filter['filter']['value'])
示例2: test_get_filters_converts_strings_to_num
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_converts_strings_to_num(self):
filtr = {'col': 'A', 'op': 'in', 'val': ['6']}
res = DruidDatasource.get_filters([filtr], ['A'])
self.assertEqual(6, res.filter['filter']['value'])
filtr = {'col': 'A', 'op': '==', 'val': '6'}
res = DruidDatasource.get_filters([filtr], ['A'])
self.assertEqual(6, res.filter['filter']['value'])
示例3: test_get_filters_converts_strings_to_num
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_converts_strings_to_num(self):
filtr = {'col': 'A', 'op': 'in', 'val': ['6']}
col = DruidColumn(column_name='A')
column_dict = {'A': col}
res = DruidDatasource.get_filters([filtr], ['A'], column_dict)
self.assertEqual(6, res.filter['filter']['value'])
filtr = {'col': 'A', 'op': '==', 'val': '6'}
res = DruidDatasource.get_filters([filtr], ['A'], column_dict)
self.assertEqual(6, res.filter['filter']['value'])
示例4: test_get_filters_handles_arrays_for_string_types
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_handles_arrays_for_string_types(self):
filtr = {'col': 'A', 'op': '==', 'val': ['a', 'b']}
col = DruidColumn(column_name='A')
column_dict = {'A': col}
res = DruidDatasource.get_filters([filtr], [], column_dict)
self.assertEqual('a', res.filter['filter']['value'])
filtr = {'col': 'A', 'op': '==', 'val': []}
res = DruidDatasource.get_filters([filtr], [], column_dict)
self.assertIsNone(res.filter['filter']['value'])
示例5: test_get_filters_constructs_filter_in
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_constructs_filter_in(self):
filtr = {'col': 'A', 'op': 'in', 'val': ['a', 'b', 'c']}
res = DruidDatasource.get_filters([filtr], [])
self.assertIn('filter', res.filter)
self.assertIn('fields', res.filter['filter'])
self.assertEqual('or', res.filter['filter']['type'])
self.assertEqual(3, len(res.filter['filter']['fields']))
示例6: test_get_filters_constructs_equals_for_in_not_in_single_value
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_constructs_equals_for_in_not_in_single_value(self):
filtr = {'col': 'A', 'op': 'in', 'val': ['a']}
cola = DruidColumn(column_name='A')
colb = DruidColumn(column_name='B')
column_dict = {'A': cola, 'B': colb}
res = DruidDatasource.get_filters([filtr], [], column_dict)
self.assertEqual('selector', res.filter['filter']['type'])
示例7: test_get_filters_ignores_in_not_in_with_empty_value
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_ignores_in_not_in_with_empty_value(self):
filtr1 = {'col': 'A', 'op': 'in', 'val': []}
filtr2 = {'col': 'A', 'op': 'not in', 'val': []}
col = DruidColumn(column_name='A')
column_dict = {'A': col}
res = DruidDatasource.get_filters([filtr1, filtr2], [], column_dict)
self.assertIsNone(res)
示例8: test_get_filters_constructs_filter_not_equals
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_constructs_filter_not_equals(self):
filtr = {'col': 'A', 'op': '!=', 'val': 'h'}
res = DruidDatasource.get_filters([filtr], [])
self.assertEqual('not', res.filter['filter']['type'])
self.assertEqual(
'h',
res.filter['filter']['field'].filter['filter']['value'],
)
示例9: test_get_filters_constructs_regex_filter
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_constructs_regex_filter(self):
filtr = {'col': 'A', 'op': 'regex', 'val': '[abc]'}
col = DruidColumn(column_name='A')
column_dict = {'A': col}
res = DruidDatasource.get_filters([filtr], [], column_dict)
self.assertEqual('regex', res.filter['filter']['type'])
self.assertEqual('[abc]', res.filter['filter']['pattern'])
self.assertEqual('A', res.filter['filter']['dimension'])
示例10: test_get_filters_constructs_filter_equals
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_constructs_filter_equals(self):
filtr = {'col': 'A', 'op': '==', 'val': 'h'}
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('A', res.filter['filter']['dimension'])
self.assertEqual('h', res.filter['filter']['value'])
示例11: test_get_filters_constructs_bounds_filter
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_constructs_bounds_filter(self):
filtr = {'col': 'A', 'op': '>=', 'val': 'h'}
res = DruidDatasource.get_filters([filtr], [])
self.assertFalse(res.filter['filter']['lowerStrict'])
self.assertEqual('A', res.filter['filter']['dimension'])
self.assertEqual('h', res.filter['filter']['lower'])
self.assertFalse(res.filter['filter']['alphaNumeric'])
filtr['op'] = '>'
res = DruidDatasource.get_filters([filtr], [])
self.assertTrue(res.filter['filter']['lowerStrict'])
filtr['op'] = '<='
res = DruidDatasource.get_filters([filtr], [])
self.assertFalse(res.filter['filter']['upperStrict'])
self.assertEqual('h', res.filter['filter']['upper'])
filtr['op'] = '<'
res = DruidDatasource.get_filters([filtr], [])
self.assertTrue(res.filter['filter']['upperStrict'])
示例12: test_get_filters_composes_multiple_filters
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_composes_multiple_filters(self):
filtr1 = {'col': 'A', 'op': '!=', 'val': 'y'}
filtr2 = {'col': 'B', 'op': 'in', 'val': ['a', 'b', 'c']}
cola = DruidColumn(column_name='A')
colb = DruidColumn(column_name='B')
column_dict = {'A': cola, 'B': colb}
res = DruidDatasource.get_filters([filtr1, filtr2], [], column_dict)
self.assertEqual('and', res.filter['filter']['type'])
self.assertEqual(2, len(res.filter['filter']['fields']))
示例13: test_get_filters_constructs_filter_not_equals
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_constructs_filter_not_equals(self):
filtr = {'col': 'A', 'op': '!=', 'val': 'h'}
col = DruidColumn(column_name='A')
column_dict = {'A': col}
res = DruidDatasource.get_filters([filtr], [], column_dict)
self.assertEqual('not', res.filter['filter']['type'])
self.assertEqual(
'h',
res.filter['filter']['field'].filter['filter']['value'],
)
示例14: test_get_filters_constructs_filter_not_in
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_constructs_filter_not_in(self):
filtr = {'col': 'A', 'op': 'not in', 'val': ['a', 'b', 'c']}
col = DruidColumn(column_name='A')
column_dict = {'A': col}
res = DruidDatasource.get_filters([filtr], [], column_dict)
self.assertIn('filter', res.filter)
self.assertIn('type', res.filter['filter'])
self.assertEqual('not', res.filter['filter']['type'])
self.assertIn('field', res.filter['filter'])
self.assertEqual(
3,
len(res.filter['filter']['field'].filter['filter']['fields']),
)
示例15: test_get_filters_extraction_fn_map
# 需要导入模块: from superset.connectors.druid.models import DruidDatasource [as 别名]
# 或者: from superset.connectors.druid.models.DruidDatasource import get_filters [as 别名]
def test_get_filters_extraction_fn_map(self):
filters = [{'col': 'deviceName', 'val': ['iPhone X'], 'op': 'in'}]
dimension_spec = {
'type': 'extraction',
'dimension': 'device',
'outputName': 'deviceName',
'outputType': 'STRING',
'extractionFn': {
'type': 'lookup',
'dimension': 'dimensionName',
'outputName': 'dimensionOutputName',
'replaceMissingValueWith': 'missing_value',
'retainMissingValue': False,
'lookup': {
'type': 'map',
'map': {
'iPhone10,1': 'iPhone 8',
'iPhone10,4': 'iPhone 8',
'iPhone10,2': 'iPhone 8 Plus',
'iPhone10,5': 'iPhone 8 Plus',
'iPhone10,3': 'iPhone X',
'iPhone10,6': 'iPhone X',
},
'isOneToOne': False,
},
},
}
spec_json = json.dumps(dimension_spec)
col = DruidColumn(column_name='deviceName', dimension_spec_json=spec_json)
column_dict = {'deviceName': col}
f = DruidDatasource.get_filters(filters, [], column_dict)
assert isinstance(f.extraction_function, MapLookupExtraction)
dim_ext_fn = dimension_spec['extractionFn']
f_ext_fn = f.extraction_function
self.assertEqual(dim_ext_fn['lookup']['map'], f_ext_fn._mapping)
self.assertEqual(dim_ext_fn['lookup']['isOneToOne'], f_ext_fn._injective)
self.assertEqual(
dim_ext_fn['replaceMissingValueWith'],
f_ext_fn._replace_missing_values,
)
self.assertEqual(
dim_ext_fn['retainMissingValue'],
f_ext_fn._retain_missing_values,
)