in src/ab/plugins/db/odps_helper.py [0:0]
def table_info(self, table_name, with_row_count=False):
'''
returns table info in db
returns: {
'type': data source type,
'size': table size in KB,
'row_count': row count in db, optional,
'columns': [
{'field': 'name', 'type': 'varchar(100)', 'xlabType': 'String', 'comment': '公司名称'},
{'field': 'f1', 'type': 'double', 'xlabType': 'Double', comment': '年总销售额'}
]
'partitions': ['p1=v1/p2=v2']
'''
table = self.table(table_name)
schema = table.schema
columns = [{'field': c.name, 'type': c.type.name, 'comment': c.comment,
'xlabType': self.odps_to_xlab_type(c.type),
}
for c in schema.columns]
partitions = self.partitions(table_name)
ret = {
'type': 'odps',
'size': table.size / 1024,
# 'psy_size': table.physical_size,
'columns': columns,
'partitions': partitions
}
if with_row_count:
ret['row_count'] = self.count(table_name)
return ret