pyarrow.acero.Declaration#

classpyarrow.acero.Declaration(factory_name,ExecNodeOptionsoptions,inputs=None)#

Bases:_Weakrefable

Helper class for declaring the nodes of an ExecPlan.

A Declaration represents an unconstructed ExecNode, and potentiallymore since its inputs may also be Declarations or when constructedwithfrom_sequence.

The possible ExecNodes to use are registered with a name,the “factory name”, and need to be specified using this name, togetherwith its corresponding ExecNodeOptions subclass.

Parameters:
factory_namestr

The ExecNode factory name, such as “table_source”, “filter”,“project” etc. See the ExecNodeOptions subclasses for the exactfactory names to use.

optionsExecNodeOptions

Corresponding ExecNodeOptions subclass (matching the factory name).

inputslist ofDeclaration, optional

Input nodes for this declaration. Optional if the node is a sourcenode, or when the declaration gets combined later withfrom_sequence.

Returns:
Declaration
__init__(*args,**kwargs)#

Methods

__init__(*args, **kwargs)

from_sequence(decls)

Convenience factory for the common case of a simple sequence of nodes.

to_reader(self, bool use_threads=True)

Run the declaration and return results as a RecordBatchReader.

to_table(self, bool use_threads=True)

Run the declaration and collect the results into a table.

staticfrom_sequence(decls)#

Convenience factory for the common case of a simple sequence of nodes.

Each of the declarations will be appended to the inputs of thesubsequent declaration, and the final modified declaration willbe returned.

Parameters:
declslist ofDeclaration
Returns:
Declaration
to_reader(self,booluse_threads=True)#

Run the declaration and return results as a RecordBatchReader.

For details about the parameters, seeto_table.

Returns:
pyarrow.RecordBatchReader
to_table(self,booluse_threads=True)#

Run the declaration and collect the results into a table.

This method will implicitly add a sink node to the declarationto collect results into a table. It will then create an ExecPlanfrom the declaration, start the exec plan, block until the planhas finished, and return the created table.

Parameters:
use_threadsbool, defaultTrue

If set to False, then all CPU work will be done on the callingthread. I/O tasks will still happen on the I/O executorand may be multi-threaded (but should not use significant CPUresources).

Returns:
pyarrow.Table