• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.DruidDatasource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中superset.connectors.druid.models.DruidDatasource的典型用法代码示例。如果您正苦于以下问题:Python DruidDatasource类的具体用法?Python DruidDatasource怎么用?Python DruidDatasource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DruidDatasource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_get_filters_handles_arrays_for_string_types

 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,代码行数:7,代码来源:druid_func_tests.py


示例2: test_get_filters_converts_strings_to_num

 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,代码行数:7,代码来源:druid_func_tests.py


示例3: test_druid_type_from_adhoc_metric

    def test_druid_type_from_adhoc_metric(self):

        druid_type = DruidDatasource.druid_type_from_adhoc_metric({
            'column': {'type': 'DOUBLE', 'column_name': 'value'},
            'aggregate': 'SUM',
            'label': 'My Adhoc Metric',
        })
        assert(druid_type == 'doubleSum')

        druid_type = DruidDatasource.druid_type_from_adhoc_metric({
            'column': {'type': 'LONG', 'column_name': 'value'},
            'aggregate': 'MAX',
            'label': 'My Adhoc Metric',
        })
        assert(druid_type == 'longMax')

        druid_type = DruidDatasource.druid_type_from_adhoc_metric({
            'column': {'type': 'VARCHAR(255)', 'column_name': 'value'},
            'aggregate': 'COUNT',
            'label': 'My Adhoc Metric',
        })
        assert(druid_type == 'count')

        druid_type = DruidDatasource.druid_type_from_adhoc_metric({
            'column': {'type': 'VARCHAR(255)', 'column_name': 'value'},
            'aggregate': 'COUNT_DISTINCT',
            'label': 'My Adhoc Metric',
        })
        assert(druid_type == 'cardinality')
开发者ID:tan31989,项目名称:caravel,代码行数:29,代码来源:druid_func_tests.py


示例4: test_get_filters_converts_strings_to_num

 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,代码行数:9,代码来源:druid_func_tests.py


示例5: test_get_filters_handles_arrays_for_string_types

    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,代码行数:10,代码来源:druid_func_tests.py


示例6: test_import_druid_override_idential

    def test_import_druid_override_idential(self):
        datasource = self.create_druid_datasource(
            'copy_cat', id=10004, cols_names=['new_col1', 'col2', 'col3'],
            metric_names=['new_metric1'])
        imported_id = DruidDatasource.import_obj(
            datasource, import_time=1993)

        copy_datasource = self.create_druid_datasource(
            'copy_cat', id=10004, cols_names=['new_col1', 'col2', 'col3'],
            metric_names=['new_metric1'])
        imported_id_copy = DruidDatasource.import_obj(
            copy_datasource, import_time=1994)

        self.assertEquals(imported_id, imported_id_copy)
        self.assert_datasource_equals(
            copy_datasource, self.get_datasource(imported_id))
开发者ID:avsolatorio,项目名称:caravel,代码行数:16,代码来源:import_export_tests.py


示例7: test_metrics_and_post_aggs_tree

    def test_metrics_and_post_aggs_tree(self):
        metrics = ['A', 'B', 'm1', 'm2']
        metrics_dict = {}
        for i in range(ord('A'), ord('K') + 1):
            emplace(metrics_dict, chr(i), True)
        for i in range(1, 10):
            emplace(metrics_dict, 'm' + str(i), False)

        def depends_on(index, fields):
            dependents = fields if isinstance(fields, list) else [fields]
            metrics_dict[index].json_obj = {'fieldNames': dependents}

        depends_on('A', ['m1', 'D', 'C'])
        depends_on('B', ['B', 'C', 'E', 'F', 'm3'])
        depends_on('C', ['H', 'I'])
        depends_on('D', ['m2', 'm5', 'G', 'C'])
        depends_on('E', ['H', 'I', 'J'])
        depends_on('F', ['J', 'm5'])
        depends_on('G', ['m4', 'm7', 'm6', 'A'])
        depends_on('H', ['A', 'm4', 'I'])
        depends_on('I', ['H', 'K'])
        depends_on('J', 'K')
        depends_on('K', ['m8', 'm9'])
        all_metrics, postaggs = DruidDatasource.metrics_and_post_aggs(
            metrics, metrics_dict)
        expected_metrics = set(all_metrics)
        self.assertEqual(9, len(all_metrics))
        for i in range(1, 10):
            expected_metrics.remove('m' + str(i))
        self.assertEqual(0, len(expected_metrics))
        self.assertEqual(11, len(postaggs))
        for i in range(ord('A'), ord('K') + 1):
            del postaggs[chr(i)]
        self.assertEqual(0, len(postaggs))
开发者ID:tothandor,项目名称:incubator-superset,代码行数:34,代码来源:druid_func_tests.py


示例8: test_get_filters_constructs_equals_for_in_not_in_single_value

 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,代码行数:7,代码来源:druid_func_tests.py


示例9: test_get_filters_ignores_in_not_in_with_empty_value

 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,代码行数:7,代码来源:druid_func_tests.py


示例10: test_get_filters_constructs_filter_in

 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,代码行数:7,代码来源:druid_func_tests.py


示例11: test_import_druid_no_metadata

 def test_import_druid_no_metadata(self):
     datasource, dict_datasource = self.create_druid_datasource(
         'pure_druid', id=ID_PREFIX + 1)
     imported_cluster = DruidDatasource.import_from_dict(db.session,
                                                         dict_datasource)
     db.session.commit()
     imported = self.get_datasource(imported_cluster.id)
     self.assert_datasource_equals(datasource, imported)
开发者ID:neuroradiology,项目名称:caravel,代码行数:8,代码来源:dict_import_export_tests.py


示例12: test_get_filters_constructs_regex_filter

 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,代码行数:8,代码来源:druid_func_tests.py


示例13: test_get_filters_constructs_bounds_filter

 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,代码行数:17,代码来源:druid_func_tests.py


示例14: test_get_filters_constructs_filter_not_equals

 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,代码行数:8,代码来源:druid_func_tests.py


示例15: test_import_druid_2_col_2_met

 def test_import_druid_2_col_2_met(self):
     datasource = self.create_druid_datasource(
         'druid_2_col_2_met', id=10003, cols_names=['c1', 'c2'],
         metric_names=['m1', 'm2'])
     imported_id = DruidDatasource.import_obj(
         datasource, import_time=1991)
     imported = self.get_datasource(imported_id)
     self.assert_datasource_equals(datasource, imported)
开发者ID:avsolatorio,项目名称:caravel,代码行数:8,代码来源:import_export_tests.py


示例16: test_get_filters_constructs_filter_equals

 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,代码行数:8,代码来源:druid_func_tests.py


示例17: test_get_aggregations

    def test_get_aggregations(self):
        ds = DruidDatasource(datasource_name='datasource')
        metrics_dict = {
            'sum1': DruidMetric(
                metric_name='sum1',
                metric_type='doubleSum',
                json=json.dumps({'type': 'doubleSum', 'name': 'sum1'}),
            ),
            'sum2': DruidMetric(
                metric_name='sum2',
                metric_type='doubleSum',
                json=json.dumps({'type': 'doubleSum', 'name': 'sum2'}),
            ),
            'div1': DruidMetric(
                metric_name='div1',
                metric_type='postagg',
                json=json.dumps({
                    'fn': '/',
                    'type': 'arithmetic',
                    'name': 'div1',
                    'fields': [
                        {
                            'fieldName': 'sum1',
                            'type': 'fieldAccess',
                        },
                        {
                            'fieldName': 'sum2',
                            'type': 'fieldAccess',
                        },
                    ],
                }),
            ),
        }
        metric_names = ['sum1', 'sum2']
        aggs = ds.get_aggregations(metrics_dict, metric_names)
        expected_agg = {name: metrics_dict[name].json_obj for name in metric_names}
        self.assertEqual(expected_agg, aggs)

        metric_names = ['sum1', 'col1']
        self.assertRaises(
            SupersetException, ds.get_aggregations, metrics_dict, metric_names)

        metric_names = ['sum1', 'div1']
        self.assertRaises(
            SupersetException, ds.get_aggregations, metrics_dict, metric_names)
开发者ID:tan31989,项目名称:caravel,代码行数:45,代码来源:druid_func_tests.py


示例18: test_get_filters_composes_multiple_filters

 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,代码行数:9,代码来源:druid_func_tests.py


示例19: test_import_druid_2_col_2_met

 def test_import_druid_2_col_2_met(self):
     datasource, dict_datasource = self.create_druid_datasource(
         'druid_2_col_2_met', id=ID_PREFIX + 3, cols_names=['c1', 'c2'],
         metric_names=['m1', 'm2'])
     imported_cluster = DruidDatasource.import_from_dict(db.session,
                                                         dict_datasource)
     db.session.commit()
     imported = self.get_datasource(imported_cluster.id)
     self.assert_datasource_equals(datasource, imported)
开发者ID:neuroradiology,项目名称:caravel,代码行数:9,代码来源:dict_import_export_tests.py


示例20: test_import_druid_override_identical

    def test_import_druid_override_identical(self):
        datasource, dict_datasource = self.create_druid_datasource(
            'copy_cat', id=ID_PREFIX + 4,
            cols_names=['new_col1', 'col2', 'col3'],
            metric_names=['new_metric1'])
        imported = DruidDatasource.import_from_dict(session=db.session,
                                                    dict_rep=dict_datasource)
        db.session.commit()
        copy_datasource, dict_cp_datasource = self.create_druid_datasource(
            'copy_cat', id=ID_PREFIX + 4,
            cols_names=['new_col1', 'col2', 'col3'],
            metric_names=['new_metric1'])
        imported_copy = DruidDatasource.import_from_dict(db.session,
                                                         dict_cp_datasource)
        db.session.commit()

        self.assertEquals(imported.id, imported_copy.id)
        self.assert_datasource_equals(
            copy_datasource, self.get_datasource(imported.id))
开发者ID:neuroradiology,项目名称:caravel,代码行数:19,代码来源:dict_import_export_tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.SqlaTable类代码示例发布时间:2022-05-27
下一篇:
Python connector_registry.ConnectorRegistry类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap