Skip to content

segments= and pre= give wrong results or errors on PyArrow tables #592

Done

Description

@tushar-mahalya

Prework

Description

With a pyarrow.Table, segments=("col", value) doesn't filter, so every segment is checked against all rows and the pass/fail counts are wrong without any error. segments="col" ends in an evaluation error (Unsupported table type: pyarrow), and any pre= ends in an evaluation error because the column names are collected with set(tbl.columns), which is a list of ChunkedArray on PyArrow. The same steps on a Polars or pandas table work.

Reproducible example

  • Post a minimal reproducible example (MRE) so the maintainer can troubleshoot the problems you identify.
import pyarrow as pa
import pyarrow.compute as pc
import pointblank as pb

tbl = pa.table({"n": [1, 2, 3, 4], "seg": ["a", "a", "b", None]})

v = pb.Validate(tbl).col_vals_gt("n", 1, segments=("seg", "b")).interrogate()
print([(i.n, i.n_passed) for i in v.validation_info])   # [(4, 3)]

v = pb.Validate(tbl).col_vals_gt("n", 1, segments="seg").interrogate()
print([i.eval_error for i in v.validation_info])        # [True]

v = pb.Validate(tbl).col_vals_gt("m", 1, pre=lambda t: t.append_column("m", pc.multiply(t["n"], 2))).interrogate()
print([i.eval_error for i in v.validation_info])        # [True]

Expected result

The first should print [(1, 1)] (only the "b" row), the second should give one step per segment (a, b and the missing value) without errors, and the third should run without an error, as they do with Polars.

Development environment

  • Operating System: macOS
  • Pointblank Version: 0.1.dev6327+gdb80d5f0d (main at db80d5f)

Additional context

The fix with tests is in #593.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions