修复Superset中连接Hive表名都相同的问题

题外话:个人觉得Superset的完成度真的不高,而且python各种新旧依赖真的头痛,官方的文档也查不到,还好基于python好修改问题

参考:https://github.com/apache/superset/issues/16509
现象:
image.png
原因代码
pyhive/sqlalchemy_hive.py

def get_table_names(self, connection, schema=None, **kw):
    query = 'SHOW TABLES'
    if schema:
        query += ' IN ' + self.identifier_preparer.quote_identifier(schema)
    return [row[0] for row in connection.execute(query)]

这段代码就是取出所有的列返回字典,但是问题就是row不应该取0,应该取1
image.png
修改代码

def get_table_names(self, connection, schema=None, **kw):
    query = 'SHOW TABLES'
    if schema:
        query += ' IN ' + self.identifier_preparer.quote_identifier(schema)
    return [row[1] for row in connection.execute(query)]

问题解决!
image.png

posted @ 2023-03-18 18:34  隔篁竹闻水声  阅读(134)  评论(0)    收藏  举报