[hive] Tables are missing first column in Assist with Hive on Tez
@@ -112,15 +112,15 @@ class HiveServerTable(Table):
@property
def cols(self):
rows = self.describe
- col_row_index = 1
+ col_row_index = 0
try:
- cols = list(map(itemgetter('col_name'), rows[col_row_index:]))
- if cols.index('') == 0: # TEZ starts at 1 vs Hive, Impala starts at 2
- col_row_index = col_row_index + 1
- cols.pop(0)
+ cols = [col.strip() for col in map(itemgetter('col_name'), rows[col_row_index:])]
+ if cols[0] == '# col_name': # Hive MR/Impala have headers and one blank line, Hive Tez has nothing
+ col_row_index = 2
+ cols = cols[2:]
end_cols_index = cols.index('')
return rows[col_row_index:][:end_cols_index] + self._get_partition_columns()
- except ValueError: # DESCRIBE on columns and nested columns does not always contain additional rows beyond cols
+ except ValueError: # DESCRIBE on nested columns does not always contain additional rows beyond cols
return rows[col_row_index:]
except:
# Impala does not have it
