//! Shared test helpers for tree tests
//!
//! This module contains common utilities used across multiple test modules
//! to reduce duplication and ensure consistency.

use std::sync::Arc;

use ordermap::OrderMap;

use crate::catalog::CatalogProvider;
use crate::sql::expression::identifier::{Identifier, SimpleIdentifier};
use crate::types::Type;

/// Helper to create a catalog provider with table schemas
pub fn catalog_with_tables(tables: Vec<(&str, Vec<(&str, Type)>)>) -> Arc<CatalogProvider> {
    let mut datasets = std::collections::HashMap::new();

    for (table_name, fields) in tables {
        let table_id: Identifier = table_name.parse().unwrap();
        let mut field_map = OrderMap::new();
        for (field_name, field_type) in fields {
            let field_id: SimpleIdentifier = field_name.parse().unwrap();
            field_map.insert(field_id, field_type);
        }
        datasets.insert(table_id, field_map);
    }

    Arc::new(CatalogProvider::new(datasets))
}
