def table_info()

in src/ab/plugins/db/hive.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', 'xlabType': 'String', 'comment': '公司名称'},
                {'field': 'f1', 'type': 'double', 'xlabType': 'Double', comment': '年总销售额'}
                ],
            'partitions': ['p1=v1/p2=v2']
        '''
        table = self.table(table_name)
        columns = [{'field': c.name, 'type': str(c.type).lower(), 'xlabType': self.hive_to_xlab_type(c.type),
                    'comment': c.comment or ''} for _, c in table.columns.items()]
        partitions = self.partitions(table_name)

        ret = {
            'type': 'hive',
            'size': self.get_table_size_in_KB(table_name),
            'columns': columns,
            'partitions': partitions,
        }
        if with_row_count:
            pass
        return ret