import polars as pl
from typing import List

REQUIRED_COLUMNS = [
    "cloud_provider",
    "service",
    "usage_family",
    "resource_type",
    "operation",
    "usage_type",
    "instance_type",
]


def validate_schema(df: pl.DataFrame) -> List[str]:
    errors = []

    for col in REQUIRED_COLUMNS:
        if col not in df.columns:
            errors.append(f"Missing required column: {col}")
        elif df[col].dtype != pl.Utf8:
            errors.append(
                f"Column '{col}' must be string (Utf8), found {df[col].dtype}"
            )

    # Check for nulls in all columns except instance_type
    for col in REQUIRED_COLUMNS:
        if col == "instance_type":
            continue
        if col in df.columns and df[col].null_count() > 0:
            errors.append(f"Column '{col}' contains null values")

    return errors
