Data

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:

  • RecordInfo holds a list of FieldInfo objects that have the field names, types, sizes, and position, which do not change between records.
  • RecordRef has a blob of bytes that are not in a set structure. To manipulate the RecordRef, you need the matching RecordInfo.

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.

Create records

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:

RecordInfo(alteryx_engine)

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

output_anchor.init(record_info_output)

Once you've created a RecordCreator and a RecordCopier, construct an output record from an input record:

  1. reset the RecordCreator.
  2. copy the data from the input record to the RecordCreator using the RecordCopier.
  3. 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 output_anchor.push_record(record_out).

Data management examples

For example, if your tool takes input, data from an incoming connection could follow the steps below:

  1. An upstream tool sends __ii_it__ with a RecordInfo argument. The RecordInfo argument can be copied, modified, and passed along to downstream tools.
  2. An upstream tool passes a record as an argument to ii_push_record. The record conforms to the structure of the RecordInfo initially received.
  3. Your tool uses the data from the record to create a new record that conforms to the structure of the RecordInfo initially received.

If your tool does not take input, your tool could follow the steps below:

  1. Create a new RecordInfo object.
  2. Create records from your data source that conform to the structure of the RecordInfo object.
  3. Use pi_push_all_records to send the records to downstream tools.