当前位置: 首页>>代码示例>>Python>>正文


Python DruidDatasource.get_filters方法代码示例

本文整理汇总了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'])
开发者ID:tothandor,项目名称:incubator-superset,代码行数:9,代码来源:druid_func_tests.py

示例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'])
开发者ID:tothandor,项目名称:incubator-superset,代码行数:9,代码来源:druid_func_tests.py

示例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'])
开发者ID:tan31989,项目名称:caravel,代码行数:11,代码来源:druid_func_tests.py

示例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'])
开发者ID:tan31989,项目名称:caravel,代码行数:12,代码来源:druid_func_tests.py

示例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']))
开发者ID:tothandor,项目名称:incubator-superset,代码行数:9,代码来源:druid_func_tests.py

示例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'])
开发者ID:tan31989,项目名称:caravel,代码行数:9,代码来源:druid_func_tests.py

示例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)
开发者ID:tan31989,项目名称:caravel,代码行数:9,代码来源:druid_func_tests.py

示例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'],
     )
开发者ID:tothandor,项目名称:incubator-superset,代码行数:10,代码来源:druid_func_tests.py

示例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'])
开发者ID:tan31989,项目名称:caravel,代码行数:10,代码来源:druid_func_tests.py

示例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'])
开发者ID:tan31989,项目名称:caravel,代码行数:10,代码来源:druid_func_tests.py

示例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'])
开发者ID:tothandor,项目名称:incubator-superset,代码行数:19,代码来源:druid_func_tests.py

示例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']))
开发者ID:tan31989,项目名称:caravel,代码行数:11,代码来源:druid_func_tests.py

示例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'],
     )
开发者ID:tan31989,项目名称:caravel,代码行数:12,代码来源:druid_func_tests.py

示例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']),
     )
开发者ID:tan31989,项目名称:caravel,代码行数:15,代码来源:druid_func_tests.py

示例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,
     )
开发者ID:tan31989,项目名称:caravel,代码行数:46,代码来源:druid_func_tests.py


注:本文中的superset.connectors.druid.models.DruidDatasource.get_filters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。