mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 09:28:51 +00:00
modify hive/impala/oracle to use BaseSQLQueryRunner
This commit is contained in:
parent
58c0c5c099
commit
61cb203ce7
@ -34,7 +34,7 @@ types_map = {
|
||||
}
|
||||
|
||||
|
||||
class Hive(BaseQueryRunner):
|
||||
class Hive(BaseSQLQueryRunner):
|
||||
@classmethod
|
||||
def configuration_schema(cls):
|
||||
return {
|
||||
@ -67,7 +67,7 @@ class Hive(BaseQueryRunner):
|
||||
def __init__(self, configuration_json):
|
||||
super(Hive, self).__init__(configuration_json)
|
||||
|
||||
def get_schema(self):
|
||||
def _get_tables(self, schema_dict):
|
||||
try:
|
||||
schemas_query = "show schemas"
|
||||
|
||||
@ -75,7 +75,6 @@ class Hive(BaseQueryRunner):
|
||||
|
||||
columns_query = "show columns in %s"
|
||||
|
||||
schema = {}
|
||||
for schema_name in filter(lambda a: len(a) > 0, map(lambda a: str(a['database_name']), self._run_query_internal(schemas_query))):
|
||||
for table_name in filter(lambda a: len(a) > 0, map(lambda a: str(a['tab_name']), self._run_query_internal(tables_query % schema_name))):
|
||||
columns = filter(lambda a: len(a) > 0, map(lambda a: str(a['field']), self._run_query_internal(columns_query % table_name)))
|
||||
|
@ -34,7 +34,7 @@ types_map = {
|
||||
}
|
||||
|
||||
|
||||
class Impala(BaseQueryRunner):
|
||||
class Impala(BaseSQLQueryRunner):
|
||||
@classmethod
|
||||
def configuration_schema(cls):
|
||||
return {
|
||||
@ -77,7 +77,7 @@ class Impala(BaseQueryRunner):
|
||||
def __init__(self, configuration_json):
|
||||
super(Impala, self).__init__(configuration_json)
|
||||
|
||||
def get_schema(self):
|
||||
def _get_tables(self, schema_dict):
|
||||
try:
|
||||
schemas_query = "show schemas;"
|
||||
|
||||
@ -85,7 +85,6 @@ class Impala(BaseQueryRunner):
|
||||
|
||||
columns_query = "show column stats %s;"
|
||||
|
||||
schema = {}
|
||||
for schema_name in map(lambda a: a['name'], self._run_query_internal(schemas_query)):
|
||||
for table_name in map(lambda a: a['name'], self._run_query_internal(tables_query % schema_name)):
|
||||
columns = map(lambda a: a['Column'], self._run_query_internal(columns_query % table_name))
|
||||
|
@ -35,7 +35,7 @@ except ImportError:
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Oracle(BaseQueryRunner):
|
||||
class Oracle(BaseSQLQueryRunner):
|
||||
|
||||
@classmethod
|
||||
def get_col_type(cls, col_type, scale):
|
||||
@ -88,7 +88,7 @@ class Oracle(BaseQueryRunner):
|
||||
|
||||
self.connection_string = "{}/{}@{}".format(self.configuration["user"], self.configuration["password"], dsn)
|
||||
|
||||
def get_schema(self):
|
||||
def _get_tables(self, schema_dict):
|
||||
query = """
|
||||
SELECT
|
||||
user_tables.TABLESPACE_NAME,
|
||||
@ -105,7 +105,6 @@ class Oracle(BaseQueryRunner):
|
||||
|
||||
results = json.loads(results)
|
||||
|
||||
schema = {}
|
||||
for row in results['rows']:
|
||||
if row['TABLESPACE_NAME'] != None:
|
||||
table_name = '{}.{}'.format(row['TABLESPACE_NAME'], row['TABLE_NAME'])
|
||||
|
Loading…
Reference in New Issue
Block a user