Skip to content

Commit

Permalink
fix(query): quote schema and table names correctly (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
karoliskascenas committed Aug 23, 2021
1 parent 1a1ee73 commit b2ff133
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pyhive/sqlalchemy_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,17 @@ def get_view_names(self, connection, schema=None, **kw):
return self.get_table_names(connection, schema, **kw)

def _get_table_columns(self, connection, table_name, schema, extended=False):
full_table = table_name
full_table = self.identifier_preparer.quote_identifier(table_name)
if schema:
full_table = schema + '.' + table_name
full_table = '{}.{}'.format(
self.identifier_preparer.quote_identifier(schema),
self.identifier_preparer.quote_identifier(table_name)
)
# TODO using TGetColumnsReq hangs after sending TFetchResultsReq.
# Using DESCRIBE works but is uglier.
try:
extended = " FORMATTED" if extended else ""
rows = connection.execute('DESCRIBE{} {}'.format(
extended,
self.identifier_preparer.quote_identifier(full_table))).fetchall()
rows = connection.execute('DESCRIBE{} {}'.format(extended, full_table)).fetchall()
except exc.OperationalError as e:
# Does the table exist?
regex_fmt = r'TExecuteStatementResp.*SemanticException.*Table not found {}'
Expand Down

0 comments on commit b2ff133

Please sign in to comment.