Introduction
- Start Job step
- A standard transformation with the results exported to a pipe separated text files (export happens within the transformation)
- Check if file exists
- Create InfiniDB Job file using the colxml utility
- Run bulk upload using the cpimport utility
Prepare Tables
- InfiniDB bulk load job (using mainly Kettle steps): download
- InfiniDB bulk load job (using shell): download
- Sample transformation: download
- We have some sort of input etc, which we will not discuss here.
- After the Group By step we add a Switch/Case step and create a hub from the first one to the second one
- Add a Dummy step and a Text file output step
- Create a hub from the Switch/Case step to the Dummy step
- Create a hub from the Switch/Case step to the Text file output step
- Now double click on the Switch/Case step and fill it out:
- Set filed name to switch to the count field (but in theory it can be any field, as long as you know that it is definitely populate when data is available)
- We add only one case leaving the value empty and setting the target step to a Dummy step. Leaving the value empty means that the field has to be NULL. So in case there are no records in the stream, the stream will be directed to the Dummy step.
- The default target step is the Text file output step
- Double click the Text file output:
- Set the filename to /usr/local/Calpont/data/bulk/data/import/<tablename>. Replace <tablename> with the actual table name.
- Set Extension to tbl
- Click on the Content tab:
- Set Separator to |
- Leave the Enclosure field empty
- Tick Enable the enclosure fix?
- Untick Header
- Set Format to Unix
- Set Encoding to UTF-8. Note: InfiniDB only accepts UTF-8!
- Fields tab: If your fields are not in the same order as the database columns, make sure you bring them now into the right order.
Using mainly Kettle steps
- You don't have to write a shell script and
- It is OS independent.
- Check if file exists step
- Execute a shell script step: Create InfiniDB job file
- Execute a shell script step: Execute bulk upload
Check if file exists
- a Start step
- a Transformation step and link it to your main transformation
- Add a Check if file exists step to the canvas
- Create hubs between the first three steps
- Add two Execute a shell script steps.
- Create a "Follow when result is true" hub to the 1st Execute a shell script step
- Create a "Follow when result is true" hub from the first Execute a shell script step to the second one.
- Add a Delete file step. Create a hub from the 2nd Execute a shell script step to this one.
- Double click on the Check if file exists step:
- Add following file path: /usr/local/Calpont/data/bulk/data/import/fact_impression.tbl
Setup Infinidb job files
- Double click on Load Tables and make sure the Insert script is ticked.
- Set the Working directory to /usr/local/Calpont/bin/
- Click the Script tab and insert following lines:
Load Tables
- Double click on Load Tables and make sure Insert script is ticked.
- Set the Working directory to /usr/local/Calpont/bin/
- Click the Script tab and insert following lines:
Delete text file
- Insert a Delete file step
- Create a hop from the load Load Tables step to this one.
- Double click on the Delete file step
- Insert into the File/Folder cell the following: /usr/local/Calpont/data/bulk/data/import/fact_impression.tbl
Round up
Using the power of shell scripts
Setup Infinidb job files
- a Start step
- a Transformation step and link it to your main transformation
- an Execute a shell script step; name it Setup Bulk Job.
- Create a hub from the Start step to the Transformation step and another one from the Transformation step to the Execute a shell script step
- Double click on Load Tables and make sure Insert script is ticked.
- Set the Working directory to /usr/local/Calpont/bin/
- Click the Script tab and insert following lines:
Load Tables
- Double click on Load Tables and make sure the Insert script is ticked.
- Set the Working directory to /usr/local/Calpont/bin/
- Click the Script tab and insert following lines:
cpimport is the Infinidb bulk load utility. It accepts the job number as a command line argument. For additional arguments please reference the Infinidb Admin manual.
Delete text files
- Insert a Delete files step
- Create a hop from the load Load Tables step to this one.
- Double click on the Delete files step
- Insert into the File/Folder cell the following: /usr/local/Calpont/data/bulk/data/import
- and into the Wildcard (RegEx) cell: ^.+\.tbl$
Round up
If things go wrong ... Error log is your friend
- errors can be found in job_#.err
- successful jobs will be logged in job_#.log
- If the data of the import file does not match the table definition, then a file tablename.tbl.bad will be created.
Files and references
Some information for this article was taken from the Calpont Infinidb manuals as well as from the Pentaho forums.