​
Inspect the plan

Call explain_logical() on an intermediate frame to inspect the columns and operations that lead to its result. Read the plan from its input at the bottom to its final operation at the top.

import pyarrow as pa
from chalk import _
from chalkdf import DataFrame

tx = DataFrame({"user": ["a", "a", "b"], "amount": [12, 8, 30]})

query = tx.filter(_.amount >= 10).select("user", "amount")
pa.table({"logical_plan": query.explain_logical().splitlines()})
#
logical_planstring
1#0 Project (projections=['user':user, 'amount':amount])
2└── #1 Filter (mask=gte(amount, 10))
3└── #2 ValuesNode (num_batches=1, num_rows=3)

​
Materialize the rows

Request the result after inspecting the plan.

query.run()
#
userstring
amountint64
1a12
2b30

To inspect the plan selected for execution, call query.explain_physical().

​
Work with the result

Save result = query.run() to reuse the materialized rows. For a Python consumer that accepts Arrow, use query.to_arrow(). Each request to execute a lazy frame can run its plan again.

​
Named table inputs

Use DataFrame.named_table to build a plan before its rows arrive. Declare the input schema once, then supply each batch under the same name. If your batch is already a ChalkDF frame, pass its Arrow table to run(tables=...).

schema = pa.schema([("id", pa.string()), ("amount", pa.int32())])
orders = DataFrame.named_table("orders", schema)
large_orders = orders.filter(_.amount >= 10)

batch = DataFrame({"id": ["001", "002"], "amount": pa.array([8, 30], type=pa.int32())})
large_orders.run(tables={"orders": batch.to_arrow()})
#
idstring
amountint32
100230

See DataFrame.explain_logical, DataFrame.explain_physical, DataFrame.run, DataFrame.to_arrow.

To submit the same plan to a worker and retrieve its results, see Run Remotely.