|
@@ -74,14 +74,29 @@ class HiveDS(DataSourceBase):
|
|
|
|
|
|
def get_table_schema(self, table_name):
|
|
|
logger.info(self.database_name)
|
|
|
- sql = f'describe {self.database_name}.{table_name}'
|
|
|
- res = self._execute_sql([sql])
|
|
|
+ sql1 = f'show columns in {self.database_name}.{table_name}'
|
|
|
+ res = self._execute_sql([sql1])
|
|
|
if res:
|
|
|
- print(res[0])
|
|
|
- res = [[str(i) , *x]for i, x in enumerate(filter(lambda x: x[0] != '', res[0]))]
|
|
|
- logger.info(res)
|
|
|
- return flat_map(lambda x: [':'.join(x[:3])], res)
|
|
|
+ logger.info(res[0])
|
|
|
+ columns = list(map(lambda x: x[0],res[0]))
|
|
|
+ logger.info(columns)
|
|
|
else:
|
|
|
- raise Exception('table not found')
|
|
|
-
|
|
|
+ raise Exception(f'{table_name} no columns')
|
|
|
+ ans = []
|
|
|
+ for col in columns:
|
|
|
+ sql = f'describe {self.database_name}.{table_name} {col}'
|
|
|
+ try:
|
|
|
+ res = self._execute_sql([sql])
|
|
|
+ if res:
|
|
|
+ print(res[0])
|
|
|
+ res = [[str(i) , *x]for i, x in enumerate(filter(lambda x: x[0] != '', res[0]))]
|
|
|
+ logger.info(res[1:3])
|
|
|
+ ans.append(flat_map(lambda x: [':'.join(x[:3])], res))
|
|
|
+
|
|
|
+ else:
|
|
|
+ raise Exception('table not found')
|
|
|
+ except Exception:
|
|
|
+ return ans
|
|
|
+
|
|
|
+ return ans
|
|
|
|