通过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

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值