def analyze_tables(self, analysis, tables=[], as_sql=False, **kwargs):
    'Base function for table level analysis'
    if (analysis not in self.template_dict['analysis']):
        raise Exception("'{}' not found in template for '{}'.".format(analysis, self.type))
    if ((not tables) and ('schema' in kwargs)):
        rows = self.get_schemas(kwargs['schema'])
        crt_obj = (lambda r: struct(dict(schema=r.schema, table=r.object_name)))
        objs = [crt_obj(r) for r in rows]
    else:
        crt_obj = (lambda schema, table: struct(dict(schema=schema, table=table)))
        objs = [crt_obj(*self._split_schema_table(t)) for t in tables]
    sql = ' \nunion all\n'.join([self._template(('analysis.' + analysis)).format(schema=obj.schema, table=obj.table, **kwargs) for obj in objs])
    return (sql if as_sql else self.query(sql, analysis, echo=False))
Base function for table level analysis
def analyze_tables(self, analysis, tables=[], as_sql=False, **kwargs):
    
    if (analysis not in self.template_dict['analysis']):
        raise Exception("'{}' not found in template for '{}'.".format(analysis, self.type))
    if ((not tables) and ('schema' in kwargs)):
        rows = self.get_schemas(kwargs['schema'])
        crt_obj = (lambda r: struct(dict(schema=r.schema, table=r.object_name)))
        objs = [crt_obj(r) for r in rows]
    else:
        crt_obj = (lambda schema, table: struct(dict(schema=schema, table=table)))
        objs = [crt_obj(*self._split_schema_table(t)) for t in tables]
    sql = ' \nunion all\n'.join([self._template(('analysis.' + analysis)).format(schema=obj.schema, table=obj.table, **kwargs) for obj in objs])
    return (sql if as_sql else self.query(sql, analysis, echo=False))