通过superset 访问HBase (phoenix)

Superset 无法直接访问 HBase, 但是可以通过 Phoenix 来与 HBase 做交互。

目前SQLAlchemy并没有直接支持hbase的引擎,需要利用第三方包来完成配置。

查询到相关包主要有 pyPhoenix , phoenixdb, sqlalchemy-phoenix

操作如下:

source superset/bin/activate 进入superset虚拟包后 执行

pip3 install  pyPhoenix

pip3 install  phoenixdb

在phoenix客户端启动 Phoenix Query Server

The server component is managed through bin/queryserver.py. Its usage is as follows

cd $PHOENIX_HOME

bin/queryserver.py start

默认端口为8765

在superset 添加phoenix:

 

添加成功后 如果不能正常返回报错:'<' not supported between instances of 'str' and 'NoneType'

这是由于源代码问题 需要修改源代码:

cd $superset_home

my install path :/mnt/modules/superset/lib/python3.6/site-packages/superset/models/core.py

vi /mnt/modules/superset/lib/python3.6/site-packages/superset/models/core.py

找到

def all_schema_names(self, force_refresh=False):

源代码:

    def all_schema_names(self, force_refresh=False):
        extra = self.get_extra()
        medatada_cache_timeout = extra.get('metadata_cache_timeout', {})
        schema_cache_timeout = medatada_cache_timeout.get('schema_cache_timeout')
        enable_cache = 'schema_cache_timeout' in medatada_cache_timeout

        return sorted(self.db_engine_spec.get_schema_names(
            inspector=self.inspector,
            enable_cache=enable_cache,
            cache_timeout=schema_cache_timeout,
            db_id=self.id,
            force=force_refresh))

修改为:

    def all_schema_names(self, force_refresh=False):
        extra = self.get_extra()
        medatada_cache_timeout = extra.get('metadata_cache_timeout', {})
        schema_cache_timeout = medatada_cache_timeout.get('schema_cache_timeout')
        enable_cache = 'schema_cache_timeout' in medatada_cache_timeout

       
        all_tables = self.db_engine_spec.get_schema_names(
            inspector=self.inspector,
            enable_cache=enable_cache,
            cache_timeout=schema_cache_timeout,
            db_id=self.id,
            force=force_refresh)
        return sorted([item for item in all_tables if item is not None])

thupdi-feijoe

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页