* add check for columns number

* reformat changes

Co-authored-by: Stanislav Lysikov <s.lysikov@space307.com>
Co-authored-by: Ayush Shah <ayush@getcollate.io>
This commit is contained in:
Stas Lysikov 2022-04-12 13:23:28 +03:00 committed by GitHub
parent 15766e85a6
commit 7f0aaaef62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,7 +52,26 @@ def get_columns(self, connection, table_name, schema=None, **kw):
return result
def get_table_names(self, connection, schema=None, **kw):
query = "SHOW TABLES"
if schema:
query += " IN " + self.identifier_preparer.quote_identifier(schema)
tables_in_schema = connection.execute(query)
tables = []
for row in tables_in_schema:
# check number of columns in result
# if it is > 1, we use spark thrift server with 3 columns in the result (schema, table, is_temporary)
# else it is hive with 1 column in the result
if len(row) > 1:
tables.append(row[1])
else:
tables.append(row[0])
return tables
HiveDialect.get_columns = get_columns
HiveDialect.get_table_names = get_table_names
from metadata.generated.schema.entity.services.connections.database.hiveConnection import (
HiveSQLConnection,