The data processed by Alteryx is expressed as a series of records, where each record in a series has the same field names and field types. There are two primary references to data:
RecordInfoholds a list of FieldInfo objects that have the field names, types, sizes, and position, which do not change between records.
RecordRefhas a blob of bytes that are not in a set structure. To manipulate the
RecordRef, you need the matching
When you write a Python tool, the
RecordInfo is managed first because
RecordInfo is passed between tools as an argument of
__ii_init__ to identify data types that are part of the record.
A new RecordInfo object can be created in a few ways, but the essential aspect of creation is that creating one requires the AlteryxEngine object that is passed into the constructor for your plugin. There are various values that can be used as configuration values, and the order and number of arguments determine which engine function is called.
The simplest RecordInfo object creation:
A more complex creation the sets a length limit for strings and applies rules for field names:
RecordInfo(255, True, alteryx_engine)
The most common creation is to use the clone method on the incoming RecordInfo object from upstream. This method provides a new RecordInfo object identical to the one you called it on, useful when adding a new field or modifying a single field.
Once you have your RecordInfo object, you need to extract information and add new fields.
You can create a RecordCreator by calling
construct_record_creator on the RecordInfo object. You can also set up a RecordCopier, which will do the work of copying data from an input Record to a newly created output Record. Finally, obtain references to any of the fields that will be manually set instead of automatically copied.
To send your RecordInfo object downstream, use the OutputAnchor you created earlier and call
Once you've created a RecordCreator and a RecordCopier, construct an output record from an input record:
- reset the RecordCreator.
- copy the data from the input record to the RecordCreator using the RecordCopier.
- set the output field to a value in the RecordCreator, and then finalize the RecordCreator to produce a new record.
To send a Record object downstream, use the OutputAnchor and call
Data Management Examples
For example, if your tool takes input, data from an incoming connection could follow the steps below:
- An upstream tool sends
RecordInfoargument. The RecordInfo argument can be copied, modified, and passed along to downstream tools.
- An upstream tool passes a record as an argument to
ii_push_record. The record conforms to the structure of the
- Your tool uses the data from the record to create a new record that conforms to the structure of the
If your tool does not take input, your tool could follow the steps below:
- Create a new
- Create records from your data source that conform to the structure of the
pi_push_all_recordsto send the records to downstream tools.