athena_rs 3.23.0

Hyper performant polyglot Database driver
Documentation
//! Missing-column aggregation helpers for `/debug/schema` still-needed diagnostics.
//!
//! This module isolates missing-column key derivation from overall still-needed
//! response orchestration.

use std::collections::BTreeSet;

use super::debug_evaluation::ExpectedTablesEvaluation;
use super::debug_observed_tables::relation_key;

/// Collects missing column keys (`schema.table.column`) for required/optional tables.
pub(super) fn collect_missing_column_keys(
    evaluation: &ExpectedTablesEvaluation,
    required: bool,
) -> Vec<String> {
    let mut missing_columns: BTreeSet<String> = BTreeSet::new();
    for row in &evaluation.expected_tables {
        if row.required != required {
            continue;
        }
        let table_key = relation_key(&row.table_schema, &row.table_name);
        for column in &row.missing_columns {
            missing_columns.insert(format!("{}.{}", table_key, column));
        }
    }
    missing_columns.into_iter().collect()
}