modify hive/impala/oracle to use BaseSQLQueryRunner

This commit is contained in:
Alexander Leibzon 2015-12-01 13:38:17 +02:00
parent 58c0c5c099
commit 61cb203ce7
3 changed files with 6 additions and 9 deletions

View File

@ -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)))

View File

@ -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))

View File

@ -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'])