dataframe-0.7.0.0: A fast, safe, and intuitive DataFrame library.
Safe HaskellNone
LanguageHaskell2010

DataFrame.Internal.Interpreter

Synopsis

New core API

data Value a where Source #

The result of interpreting an expression. Keeps literals as scalars until the point where a concrete column is needed, avoiding premature broadcast allocations.

Constructors

Scalar :: forall a. Columnable a => a -> Value a

A single value, not yet broadcast to any length.

Flat :: forall a. Columnable a => Column -> Value a

A flat column (one element per row in the flat case, or one element per group after aggregation).

Group :: forall a. Columnable a => Vector Column -> Value a

A grouped column: one Column slice per group. Only produced when interpreting inside a GroupCtx.

data Ctx Source #

The interpretation context.

eval :: Columnable a => Ctx -> Expr a -> Either DataFrameException (Value a) Source #

Evaluate an expression in a given context, producing a Value. This single function replaces both the old interpret (flat) and interpretAggregation (grouped) code paths.

materialize :: Columnable a => Int -> Value a -> Column Source #

Force a Value into a flat Column of the given length. Scalars are broadcast; flat columns are returned as-is.

Backward-compatible API

interpret :: Columnable a => DataFrame -> Expr a -> Either DataFrameException (TypedColumn a) Source #

Interpret an expression against a flat DataFrame, producing a typed column. This is the original top-level entry point; internally it calls eval and materialises the result.

NOTE: unlike the old implementation, Lit values are no longer eagerly broadcast. The broadcast happens here, at the boundary, via materialize.

interpretAggregation :: Columnable a => GroupedDataFrame -> Expr a -> Either DataFrameException (AggregationResult a) Source #

Interpret an expression against a GroupedDataFrame, distinguishing aggregated results from bare column references. Internally calls eval.

data AggregationResult a Source #

Result of interpreting an expression in a grouped context. Retained for backward compatibility with aggregate and friends.