|
@@ -346,7 +346,14 @@ class HiveServer2Dbms(object):
|
|
|
if self.server_name == 'impala':
|
|
if self.server_name == 'impala':
|
|
|
hql = 'COMPUTE STATS `%(database)s`.`%(table)s`' % {'database': database, 'table': table}
|
|
hql = 'COMPUTE STATS `%(database)s`.`%(table)s`' % {'database': database, 'table': table}
|
|
|
else:
|
|
else:
|
|
|
- hql = 'ANALYZE TABLE `%(database)s`.`%(table)s` COMPUTE STATISTICS' % {'database': database, 'table': table}
|
|
|
|
|
|
|
+ table_obj = self.get_table(database, table)
|
|
|
|
|
+ partition_spec = ''
|
|
|
|
|
+ if table_obj.partition_keys:
|
|
|
|
|
+ partition_keys = ','.join([part.name for part in table_obj.partition_keys])
|
|
|
|
|
+ partition_spec = 'PARTITION(%(partition_keys)s)' % {'partition_keys': partition_keys}
|
|
|
|
|
+
|
|
|
|
|
+ hql = 'ANALYZE TABLE `%(database)s`.`%(table)s` %(partition_spec)s COMPUTE STATISTICS' % \
|
|
|
|
|
+ {'database': database, 'table': table, 'partition_spec': partition_spec}
|
|
|
|
|
|
|
|
return self.execute_statement(hql)
|
|
return self.execute_statement(hql)
|
|
|
|
|
|
|
@@ -355,7 +362,11 @@ class HiveServer2Dbms(object):
|
|
|
if self.server_name == 'impala':
|
|
if self.server_name == 'impala':
|
|
|
hql = 'COMPUTE STATS `%(database)s`.`%(table)s`' % {'database': database, 'table': table}
|
|
hql = 'COMPUTE STATS `%(database)s`.`%(table)s`' % {'database': database, 'table': table}
|
|
|
else:
|
|
else:
|
|
|
- hql = 'ANALYZE TABLE `%(database)s`.`%(table)s` COMPUTE STATISTICS FOR COLUMNS' % {'database': database, 'table': table}
|
|
|
|
|
|
|
+ table_obj = self.get_table(database, table)
|
|
|
|
|
+ if table_obj.partition_keys:
|
|
|
|
|
+ raise NotImplementedError('HIVE-4861: COMPUTE STATISTICS FOR COLUMNS not supported for partitioned-tables.')
|
|
|
|
|
+ else:
|
|
|
|
|
+ hql = 'ANALYZE TABLE `%(database)s`.`%(table)s` COMPUTE STATISTICS FOR COLUMNS' % {'database': database, 'table': table}
|
|
|
|
|
|
|
|
return self.execute_statement(hql)
|
|
return self.execute_statement(hql)
|
|
|
|
|
|