def create_table_column_stats_by_name(metastore_name, data): """Batch add/update table column stats""" # TODO: verify user is a service account with DBSession() as session: metastore = admin_logic.get_query_metastore_by_name(metastore_name, session=session) api_assert(metastore, "Invalid metastore") verify_metastore_permission(metastore.id, session=session) with DataTableFinder(metastore.id) as t_finder: for d in data: column = t_finder.get_table_column_by_name( schema_name=d["schema_name"], table_name=d["table_name"], column_name=d["column_name"], session=session, ) if column is not None: for s in d["stats"]: logic.upsert_table_column_stat( column_id=column.id, key=s["key"], value=s["value"], uid=current_user.id, session=session, ) return
def upsert_table_boost_score_by_name(metastore_name, data): # TODO: verify user is a service account with DBSession() as session: metastore = admin_logic.get_query_metastore_by_name(metastore_name, session=session) api_assert(metastore, "Invalid metastore") verify_metastore_permission(metastore.id, session=session) with DataTableFinder(metastore.id) as t_finder: for d in data: table = t_finder.get_table_by_name( schema_name=d["schema_name"], table_name=d["table_name"], session=session, ) if table is not None: logic.update_table(id=table.id, score=d["boost_score"], session=session) return