Uploaded image for project: 'Pentaho Data Integration - Kettle'
  1. Pentaho Data Integration - Kettle
  2. PDI-12656

As an ETL developer, I would like to set the DatabaseInterface for child transformations programmatically

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Open
    • Severity: Medium
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Not Planned
    • Component/s: API, Database, Job
    • Labels:
      None
    • Notice:
      When an issue is open, the "Fix Version/s" field conveys a target, not necessarily a commitment. When an issue is closed, the "Fix Version/s" field conveys the version that the issue was fixed in.

      Description

      To accomodate unit testing with HSQLDB, I've been setting the DatabaseInterface for transformations programmatically like this:

      private void adjustDatabase(HasDatabasesInterface hasDatabases, DatabaseMeta databaseMeta) throws TransformationException {
      DatabaseInterface databaseInterface;
      try {
      databaseInterface = DatabaseMeta.getDatabaseInterface(databaseType);
      databaseInterface.setAccessType(DatabaseMeta.TYPE_ACCESS_JNDI);
      databaseInterface.setName(this.databaseName);
      databaseInterface.setDatabaseName("${DB_JNDI_NAME}");
      databaseMeta.setDatabaseInterface(databaseInterface);
      hasDatabases.addOrReplaceDatabase(databaseMeta);
      } catch (KettleDatabaseException e)

      { throw new TransformationException("Error getting database interface " + this.databaseType, e); }

      }
      This way I can set a variable in my application context and use the Generic interface for HSQLDB testing and the PostgreSQL interface for integration testing or production. So far so good, as long as I'm only trying to do this on transformations. But when I try to run jobs with this paradigm I run into a big problem: I can set the databaseMeta for the JobMeta all right, but when the job is executed the TransMeta objects are created on the fly, and they don't inherit the database properties from the parent job . Here's the code in JobEntryTrans:

      TransMeta transMeta = null;
      switch( specificationMethod ) {
      case FILENAME:
      String filename = space.environmentSubstitute( getFilename() );
      logBasic( "Loading transformation from XML file [" + filename + "]" );
      transMeta = new TransMeta( filename, null, true, this );
      break;

      It would be nice if there were a way of inheriting the database properties, perhaps with listeners?

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            jlweb58 John Webber
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: