Collection
Using the Collection step in the builder to dynamically query data tables with multiple columns to enrich your input data
Last updated
Using the Collection step in the builder to dynamically query data tables with multiple columns to enrich your input data
Last updated
A 'Collection' is a data table that you can use to create custom outputs. In this step, you can upload data that you want to use your enrich your data.
Collections can be many megabytes in size and you can define hundreds of formats.
If you just want to upload a small table and save all of the columns contained in it against your key, you may find the Data Set step is a simpler and faster way to do this.
How might you use the 'Collection' step?
If you were building a pricing model for insurance, the address where the property is located would play a vital part in your pricing decisions.
By uploading a whole database of risk ratings for a number of different factors, you could use the 'Collection' step to query this table and enrich each quote with different risk scores, cherry picking the data you wanted to add to your quote, without having to add all of it.
Once you've added the 'Collections' step and named it, like you will with any other step in the Build tool (more on that here), you'll need to add the database you want to query.
To get started, click the cog symbol in the top right of the 'Collections' step.
Once you've opened the step, click the 'Add Data' button.
You can then copy a data table and paste it directly into Swallow, or you can drag-and-drop a CSV document, which will upload immediately.
It's worth noting that you can also use the 'Download' and 'Upload' buttons to download your Collection as a CSV and do bulk reformatting or editing of your tables if you want to.
Once your data is successfully uploaded, you'll see your full table, including header rows, is uploaded into Swallow.
For each variable you want to return from querying the table, simply click the 'Add' button at the top right of the table to begin the process, and complete the fields below.
This labels the new variable you're storing. Keep the description short and simple so you can recognise it easily in future steps.
This is output name that will be passed to the next step, and how you'll reference the input in any syntax in future steps.
This will be auto-generated based on the label you've given, but you can edit it at any time.
This the data type of the data you want to transform the input into.
You can choose from 5 data types: Boolean, Decimal, Integer, String or Date.
Collection expressions are structured in a different format to other syntax, and must begin with the prefix collection.
before the rest of your expression.
To learn more about how to structure expressions for querying Collections, find out how to debug and to see the full glossary, check out our full page on Syntax and Collections.
This is the default value you want to set.
This is the data the model will default to if the value is not defined by the customer or the transformation fails for any reason.
Once you're happy with the settings of the variable you've added from your Collection, just press the 'Save' button in the bottom right of the modal and you're ready to add more variables to the table from your Collection if you want to.
Once you're happy with all of your variables, just press the 'Save' button in the top right of the screen. You're now ready to head back to the 'Build' screen.