Repository navigation
Open
Labels
enhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is needed
Description
Summary
Currently, PolarsBackend.profile() in src/freshdata/_core/backends.py returns a hollow ProfileReport for pl.LazyFrame inputs, reporting hardcoded zeroes for row_count, null_count, and null_ratio:
# src/freshdata/_core/backends.py:112-126
def profile(self, df: pl.DataFrame | pl.LazyFrame) -> ProfileReport:
schema = df.collect_schema() if isinstance(df, pl.LazyFrame) else df.schema
cols = {}
for name, dtype in schema.items():
role = "numeric" if dtype.is_numeric() else "categorical"
cols[name] = ColumnProfile(
name=name,
inferred_role=role,
null_count=0, # <-- Hardcoded zero
null_ratio=0.0, # <-- Hardcoded zero
unique_count=0,
sample_values=(),
)
row_count = 0 if isinstance(df, pl.LazyFrame) else len(df)
return ProfileReport(row_count=row_count, column_count=len(schema), columns=cols)However, src/freshdata/polars_engine.py:126-159 already implements a high-performance, single-pass streaming aggregation query:
stat_exprs: list[pl.Expr] = [pl.len().alias("__total_rows")]
# ... builds null_count, mean, median, quantiles ...
stats = lf.select(stat_exprs).collect(engine="streaming").row(0, named=True)Motivation & Impact
- User Experience (UX): Users profiling out-of-core Parquet or Arrow datasets via
pl.scan_parquet(...)receive zero null statistics and empty metrics. - Developer Experience (DX):
PolarsBackend.suggest_plan()in_core/backends.pydoes not compute precomputed median/IQR thresholds forLazyFramelikepolars_engine.pydoes.
Proposed Solution
- Integrate the streaming expression generator from
polars_engine.pyintoPolarsBackend.profile()andPolarsBackend.suggest_plan(). - Ensure that
pl.LazyFrameinputs are profiled using a single 1-row aggregation pass (lf.select(stat_exprs).collect(engine="streaming")) rather than returning zeroed placeholders. - Guarantee that
apply_plancontinues to compile elementwise expressions without triggering.collect().
Acceptance Criteria
-
fd.profile(lazy_df)returns accuratenull_count,null_ratio, androw_countonpl.LazyFrame. -
tests/test_backend_honesty.pycontinues to pass (no.collect()duringapply_plan). - Benchmark memory profile passes without exceeding streaming RSS thresholds.
👋 Want to work on this issue?
Comment /assign below to claim it! Check out the First Contribution Guide for setup instructions.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is needed
Activity