From fb692d956758bca9d4aba980a8c418cc5788768d Mon Sep 17 00:00:00 2001 From: Usiel Riedl Date: Fri, 28 Apr 2023 15:21:19 +0200 Subject: [PATCH] Use str type for driver and name in HiveDialect PyHive's HiveDialect usage of bytes for the name and driver fields is not the norm is causing issues upstream: https://github.com/apache/superset/issues/22316 Even other dialects within PyHive use strings. SQLAlchemy does not strictly require a string, but all the stock dialects return a string, so I figure it is heavily implied. I think the risk of breaking something upstream with this change is low (but it is there ofc). I figure in most cases we just make someone's `str(dialect.driver)` expression redundant. Examples for some of the other stock sqlalchemy dialects (name and driver fields using str): https://github.com/zzzeek/sqlalchemy/blob/main/lib/sqlalchemy/dialects/sqlite/pysqlite.py#L501 https://github.com/zzzeek/sqlalchemy/blob/main/lib/sqlalchemy/dialects/sqlite/base.py#L1891 https://github.com/zzzeek/sqlalchemy/blob/main/lib/sqlalchemy/dialects/mysql/base.py#L2383 https://github.com/zzzeek/sqlalchemy/blob/main/lib/sqlalchemy/dialects/mysql/mysqldb.py#L113 https://github.com/zzzeek/sqlalchemy/blob/main/lib/sqlalchemy/dialects/mysql/pymysql.py#L59 --- pyhive/sqlalchemy_hive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyhive/sqlalchemy_hive.py b/pyhive/sqlalchemy_hive.py index 2ef49652..f39f1793 100644 --- a/pyhive/sqlalchemy_hive.py +++ b/pyhive/sqlalchemy_hive.py @@ -228,8 +228,8 @@ def _translate_colname(self, colname): class HiveDialect(default.DefaultDialect): - name = b'hive' - driver = b'thrift' + name = 'hive' + driver = 'thrift' execution_ctx_cls = HiveExecutionContext preparer = HiveIdentifierPreparer statement_compiler = HiveCompiler