Computes column-level statistics from in-memory query results.
Operates entirely on the data already present in a %Lotus.Result{} struct,
requiring no additional database queries. Statistics are computed per-column
and vary based on the detected column type (numeric, string, or temporal).
Summary
Functions
Computes statistics for a single column in the result set.
Computes statistics for all columns in the result set.
Detects the column type from its values.
Types
@type column_stats() :: map()
@type column_type() :: :numeric | :string | :temporal | :unknown
Functions
@spec compute(Lotus.Result.t(), String.t()) :: {:ok, column_stats()} | {:error, String.t()}
Computes statistics for a single column in the result set.
Returns a map with :type and type-specific statistics keys.
Returns {:error, reason} if the column is not found.
@spec compute_all(Lotus.Result.t()) :: %{required(String.t()) => column_stats()}
Computes statistics for all columns in the result set.
Returns a map of %{column_name => stats_map}.
@spec detect_column_type(Lotus.Result.t(), String.t()) :: column_type() | {:error, String.t()}
Detects the column type from its values.
Inspects non-nil values and returns :numeric, :string, :temporal, or :unknown.