def check_for_new_tables(db): tables = db.db.table_names() monitored_tables = MonitoredTable.get_monitored_tables(db.name) monitored_tables_names = set( [table.table_name for table in monitored_tables]) for table_name in tables: if table_name not in monitored_tables_names: table = MonitoredTable.setup_for_source_table(db, table_name) if table: insert_schema_changed_record(table, 'table created', None, None, None)
def check_for_new_tables(db, conf): results = [] for namespace in db.namespaces: tables = db.table_names(namespace) monitored_tables = MonitoredTable.get_monitored_tables_per_namespace( db.name, namespace) monitored_tables_names = set( [table.table_name for table in monitored_tables]) for table_name in tables: if table_name not in monitored_tables_names: table = MonitoredTable.setup_for_source_table( db, table_name, namespace) if table: create_for_detected_table(db, table) for check in table.checks: if check.name == Metric.SCHEMA_CHANGE: MetricFromCheck.add_metrics([ schema_changed_record('table detected', None, None, None, conf) ], check, conf)