import os

from sqlmesh import macro


@macro()
def padelnomics_glob(evaluator) -> str:
    """Return a quoted glob path for all padelnomics CSV gz files under LANDING_DIR.

    Used in raw models: SELECT * FROM read_csv(@padelnomics_glob(), ...)

    The LANDING_DIR variable is read from the SQLMesh config variables block first,
    then falls back to the LANDING_DIR environment variable, then to 'data/landing'.
    """
    landing_dir = evaluator.var("LANDING_DIR") or os.environ.get("LANDING_DIR", "data/landing")
    return f"'{landing_dir}/padelnomics/**/*.csv.gz'"


# Add one macro per landing zone subdirectory you create.
# Pattern: def {source}_glob(evaluator) → f"'{landing_dir}/{source}/**/*.csv.gz'"
