Skip to main content
Hitachi Vantara Lumada and Pentaho Documentation

Running Transformations

If you want to run a PDI transformation from Java code in a stand-alone application, take a look at this sample class, org.pentaho.di.sdk.samples.embedding.RunningTransformations. It sets the parameters and executes the transformation in etl/parametrized_transformation.ktr. The transform can be run from the .ktr file using runTransformationFromFileSystem() or from a PDI repository using runTransfomrationFromRepository().

  1. Always make the first call to KettleEnvironment.init() whenever you are working with the PDI APIs.
  2. Prepare the transformation. The definition of a PDI transformation is represented by a TransMeta object. You can load this object from a .ktr file, a PDI repository, or you can generate it dynamically. To query the declared parameters of the transformation definition use listParameters(), or to query the assigned values use setParameterValue().
  3. Execute the transformation. An executable Trans object is derived from the TransMeta object that is passed to the constructor. The Trans object starts and then executes asynchronously. To ensure that all steps of the Trans object have completed, call waitUntilFinished().
  4. Evaluate the transformation outcome. After the Trans object completes, you can access the result using getResult(). The Result object can be queried for success by evaluating getNrErrors(). This method returns zero (0) on success and a non-zero value when there are errors. To get more information, retrieve the transformation log lines.