{"record":{"id":"872a207194976c4f","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-query-result-for-mdx-query-mondrianinputmeta","errorCode":null,"errorMessage":"Unable to get query result for MDX query: ","messagePattern":"Unable to get query result for MDX query: ","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"plugins/mondrianinput/impl/src/main/java/org/pentaho/di/trans/steps/mondrianinput/MondrianInputMeta.java","lineNumber":173,"sourceCode":"      return; // TODO: throw an exception here\n    }\n\n    RowMetaInterface add = null;\n\n    try {\n      String mdx = getSQL();\n      if ( isVariableReplacementActive() ) {\n        mdx = space.environmentSubstitute( mdx );\n      }\n      MondrianHelper helper = new MondrianHelper( databaseMeta, catalog, mdx, space );\n      add = helper.getCachedRowMeta();\n      if ( add == null ) {\n        helper.openQuery();\n        helper.createRectangularOutput();\n        add = helper.getOutputRowMeta();\n      }\n    } catch ( KettleDatabaseException dbe ) {\n      throw new KettleStepException( \"Unable to get query result for MDX query: \" + Const.CR + sql, dbe );\n    }\n\n    // Set the origin\n    //\n    for ( int i = 0; i < add.size(); i++ ) {\n      ValueMetaInterface v = add.getValueMeta( i );\n      v.setOrigin( origin );\n    }\n\n    row.addRowMeta( add );\n  }\n\n  public String getXML() {\n    StringBuilder retval = new StringBuilder();\n\n    retval.append( \"    \"\n      + XMLHandler.addTagValue( \"connection\", databaseMeta == null ? \"\" : databaseMeta.getName() ) );\n    retval.append( \"    \" + XMLHandler.addTagValue( \"sql\", sql ) );","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mondrianinput/impl/src/main/java/org/pentaho/di/trans/steps/mondrianinput/MondrianInputMeta.java#L155-L191","documentation":"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.","triggerScenarios":"getFields invokes helper.openQuery()/createRectangularOutput() and the Mondrian connection fails, the MDX is invalid, or createRectangularOutput throws the unhandled-type error.","commonSituations":"Wrong catalog path or role in the step config; Mondrian server unreachable; MDX syntax error; cube schema changes invalidating member names in the query.","solutions":["Validate the MDX query by running it directly against the cube in an MDX client","Check the step's catalog file path and database connection settings","Review the nested KettleDatabaseException cause for the root error (auth, connection, or unhandled type)","Verify the Mondrian schema XML is valid and the referenced cube/members exist"],"exampleFix":"// before\nSELECT NON EMPTY [Broken Dimension].Members ON COLUMNS ...\n// after: fix dimension/member names\nSELECT NON EMPTY [Time].[Year].Members ON COLUMNS ...","handlingStrategy":"validation","validationCode":"// Check Mondrian connectivity and MDX validity before running the step\ntry (Connection c = DriverManager.getConnection(\"jdbc:mondrian:Catalog=file:/path/catalog.xml;Jdbc=...\")) {\n  try (Statement s = c.createStatement(); ResultSet rs = s.executeQuery(mdx)) {\n    System.out.println(\"MDX executed successfully\");\n  }\n}","typeGuard":"null","tryCatchPattern":"try {\n  stepMeta.getStepMetaInterface().getFields(row, origin, null, null, transMeta, metaStore);\n} catch (KettleStepException e) {\n  Throwable root = e;\n  while (root.getCause() != null) root = root.getCause();\n  logError(\"MDX field derivation failed: \" + root.getMessage());\n}","preventionTips":["Test the MDX query in a standalone MDX client first","Verify the catalog file path resolves on the PDI server, not just your workstation","Check role assignments in the Mondrian schema for the connecting user","Keep Mondrian schema and cube definitions under change control"],"tags":["mdx","query-failed","mondrian","step-metadata"],"backgroundTag":"database-query-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}