pentaho/pentaho-kettle · error · KettleStepException

Unable to get query result for MDX query:

Error message

Unable to get query result for MDX query: 

What it means

MondrianInputMeta.getFields determines the output row layout by opening the MDX query and producing rectangular output. If the helper throws KettleDatabaseException (connection failure, invalid MDX, unhandled cell type), it is rethrown as KettleStepException with this message plus the MDX text. It means the MDX query could not be executed to derive row metadata.

Solutions

  1. Validate the MDX query by running it directly against the cube in an MDX client
  2. Check the step's catalog file path and database connection settings
  3. Review the nested KettleDatabaseException cause for the root error (auth, connection, or unhandled type)
  4. Verify the Mondrian schema XML is valid and the referenced cube/members exist

Example fix

// before
SELECT NON EMPTY [Broken Dimension].Members ON COLUMNS ...
// after: fix dimension/member names
SELECT NON EMPTY [Time].[Year].Members ON COLUMNS ...
Defensive patterns

Strategy: validation

Validate before calling

// Check Mondrian connectivity and MDX validity before running the step
try (Connection c = DriverManager.getConnection("jdbc:mondrian:Catalog=file:/path/catalog.xml;Jdbc=...")) {
  try (Statement s = c.createStatement(); ResultSet rs = s.executeQuery(mdx)) {
    System.out.println("MDX executed successfully");
  }
}

Type guard

null

Try / catch

try {
  stepMeta.getStepMetaInterface().getFields(row, origin, null, null, transMeta, metaStore);
} catch (KettleStepException e) {
  Throwable root = e;
  while (root.getCause() != null) root = root.getCause();
  logError("MDX field derivation failed: " + root.getMessage());
}

Prevention

When it happens

Trigger: getFields invokes helper.openQuery()/createRectangularOutput() and the Mondrian connection fails, the MDX is invalid, or createRectangularOutput throws the unhandled-type error.

Common situations: Wrong catalog path or role in the step config; Mondrian server unreachable; MDX syntax error; cube schema changes invalidating member names in the query.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/872a207194976c4f. Report an issue: GitHub.

Appendix: source

Thrown at plugins/mondrianinput/impl/src/main/java/org/pentaho/di/trans/steps/mondrianinput/MondrianInputMeta.java:173

      return; // TODO: throw an exception here
    }

    RowMetaInterface add = null;

    try {
      String mdx = getSQL();
      if ( isVariableReplacementActive() ) {
        mdx = space.environmentSubstitute( mdx );
      }
      MondrianHelper helper = new MondrianHelper( databaseMeta, catalog, mdx, space );
      add = helper.getCachedRowMeta();
      if ( add == null ) {
        helper.openQuery();
        helper.createRectangularOutput();
        add = helper.getOutputRowMeta();
      }
    } catch ( KettleDatabaseException dbe ) {
      throw new KettleStepException( "Unable to get query result for MDX query: " + Const.CR + sql, dbe );
    }

    // Set the origin
    //
    for ( int i = 0; i < add.size(); i++ ) {
      ValueMetaInterface v = add.getValueMeta( i );
      v.setOrigin( origin );
    }

    row.addRowMeta( add );
  }

  public String getXML() {
    StringBuilder retval = new StringBuilder();

    retval.append( "    "
      + XMLHandler.addTagValue( "connection", databaseMeta == null ? "" : databaseMeta.getName() ) );
    retval.append( "    " + XMLHandler.addTagValue( "sql", sql ) );

View on GitHub (pinned to f3058517a1)