Table of Contents

How to retrieve a third column from a data set generator ?

About

This howto will show you how to use the data set meta generator to retrieve a meta column (ie third column) from a data set defined in a data set generator (ie data set or entity generator)

Example

Data Set

In this example, the data set is the region entity

We want to generate the data

The content of the data set is:

tabul data head region/region.csv@entity
The first 10 rows of the data resource (region/region.csv@entity):
region     code
--------   ----
Africa     2
Americas   19
Asia       142
Europe     150
Oceania    9

Generator

Using this dataset, we can generate generates 10 regions with this generator file.

kind: generator
spec:
  MaxRecordCount: 10
  Columns:
    - name: region
      Type: varchar
      data-supplier:
        type: entity
        arguments:
          name: region
    - name: code
      Type: varchar
      data-supplier:
        type: data-set-meta # the type
        arguments:
          column-data-set: region # refer to the first column that contains an entity generator
          column: code # the column in the region entity data set to return


Printing the data

You can see/generate the output with tabul print

tabul data print generator/dataset-meta-type--generator.yml@howto
region     code
--------   ----
Oceania    9
Asia       142
Africa     2
Africa     2
Europe     150
Americas   19
Africa     2
Americas   19
Americas   19
Asia       142