"""Expression helper functions organized by category.

This module re-exports all functions from category-specific modules
for backward compatibility. Functions are organized into:
- aggregation: sum, avg, min, max, count, etc.
- string: upper, lower, substring, trim, etc.
- datetime: year, month, day, date_format, etc.
- math: round, floor, ceil, sqrt, sin, cos, etc.
- window: row_number, rank, lag, lead, etc.
- array: array, array_length, array_contains, etc.
- json: json_extract, json_tuple, from_json, etc.
- misc: lit, coalesce, when, isnull, etc.
"""

from __future__ import annotations

# Import all functions from category modules
from .aggregation import (
    avg,
    collect_list,
    collect_set,
    corr,
    count,
    count_distinct,
    covar,
    max,  # noqa: A001
    min,  # noqa: A001
    percentile_cont,
    percentile_disc,
    stddev,
    sum,  # noqa: A001
    variance,
)
from .array import (
    array,
    array_append,
    array_contains,
    array_distinct,
    array_length,
    array_max,
    array_min,
    array_position,
    array_prepend,
    array_remove,
    array_sort,
    array_sum,
)
from .datetime import (
    add_months,
    current_date,
    current_timestamp,
    date_add,
    date_format,
    date_sub,
    date_trunc,
    datediff,
    day,
    dayofweek,
    dayofyear,
    from_unixtime,
    hour,
    last_day,
    minute,
    month,
    months_between,
    quarter,
    second,
    to_date,
    to_timestamp,
    unix_timestamp,
    week,
    weekofyear,
    year,
)
from .json import (
    from_json,
    json_array_length,
    json_extract,
    json_tuple,
    to_json,
)
from .math import (
    abs,  # noqa: A001
    acos,
    asin,
    atan,
    atan2,
    ceil,
    cos,
    exp,
    floor,
    hypot,
    log,
    log10,
    log2,
    power,
    pow,
    round,
    sign,
    signum,
    sin,
    sqrt,
    tan,
)
from .misc import (
    base64,
    coalesce,
    crc32,
    exists,
    explode,
    greatest,
    hash,
    isinf,
    isnan,
    isnull,
    isnotnull,
    least,
    lit,
    md5,
    monotonically_increasing_id,
    not_exists,
    rand,
    randn,
    scalar_subquery,
    sha1,
    sha2,
    soundex,
    when,
)
from .string import (
    concat,
    initcap,
    instr,
    length,
    locate,
    lower,
    lpad,
    ltrim,
    regexp_extract,
    regexp_replace,
    replace,
    rpad,
    rtrim,
    split,
    substring,
    translate,
    trim,
    upper,
)
from .window import (
    cume_dist,
    dense_rank,
    first_value,
    lag,
    last_value,
    lead,
    nth_value,
    ntile,
    percent_rank,
    rank,
    row_number,
)

__all__ = [
    # Literals and basic
    "lit",
    # Aggregation
    "sum",
    "avg",
    "min",
    "max",
    "count",
    "count_distinct",
    "stddev",
    "variance",
    "corr",
    "covar",
    "percentile_cont",
    "percentile_disc",
    "collect_list",
    "collect_set",
    # String
    "upper",
    "lower",
    "substring",
    "trim",
    "ltrim",
    "rtrim",
    "regexp_extract",
    "regexp_replace",
    "split",
    "replace",
    "length",
    "lpad",
    "rpad",
    "concat",
    "initcap",
    "instr",
    "locate",
    "translate",
    # DateTime
    "year",
    "month",
    "day",
    "dayofweek",
    "hour",
    "minute",
    "second",
    "date_format",
    "to_date",
    "current_date",
    "current_timestamp",
    "datediff",
    "add_months",
    "date_add",
    "date_sub",
    "to_timestamp",
    "unix_timestamp",
    "from_unixtime",
    "date_trunc",
    "quarter",
    "weekofyear",
    "week",
    "dayofyear",
    "last_day",
    "months_between",
    # Math
    "round",
    "floor",
    "ceil",
    "abs",
    "sqrt",
    "exp",
    "log",
    "log10",
    "sin",
    "cos",
    "tan",
    "asin",
    "acos",
    "atan",
    "atan2",
    "signum",
    "sign",
    "log2",
    "hypot",
    "pow",
    "power",
    # Window
    "row_number",
    "rank",
    "dense_rank",
    "percent_rank",
    "cume_dist",
    "nth_value",
    "ntile",
    "lag",
    "lead",
    "first_value",
    "last_value",
    # Array
    "array",
    "array_length",
    "array_contains",
    "array_position",
    "array_append",
    "array_prepend",
    "array_remove",
    "array_distinct",
    "array_sort",
    "array_max",
    "array_min",
    "array_sum",
    # JSON
    "json_extract",
    "json_tuple",
    "from_json",
    "to_json",
    "json_array_length",
    # Misc
    "coalesce",
    "greatest",
    "least",
    "when",
    "isnan",
    "isnull",
    "isnotnull",
    "isinf",
    "scalar_subquery",
    "exists",
    "not_exists",
    "explode",
    "rand",
    "randn",
    "hash",
    "md5",
    "sha1",
    "sha2",
    "base64",
    "monotonically_increasing_id",
    "crc32",
    "soundex",
]
