File size: 799 Bytes
c21180c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Validation helpers for operation parameters."""
from __future__ import annotations

from typing import Any


def validate_column_exists(column: str, schema: list[dict[str, Any]]) -> bool:
    """Check that a column exists in the schema."""
    return any(c["name"] == column for c in schema)


def validate_columns_exist(columns: list[str], schema: list[dict[str, Any]]) -> list[str]:
    """Return list of columns that don't exist."""
    existing = {c["name"] for c in schema}
    return [c for c in columns if c not in existing]


def validate_numeric_column(column: str, schema: list[dict[str, Any]]) -> bool:
    """Check that a column is numeric."""
    for c in schema:
        if c["name"] == column:
            return c.get("column_type") in ("numeric", "geo_lat_lon")
    return False