Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape schema and table #1

Merged
merged 1 commit into from
Aug 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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