{"record":{"id":"8254eba01144723c","repo":"pentaho/pentaho-kettle","slug":"mondrianinputerroronlytabular","errorCode":"MondrianInputErrorOnlyTabular","errorMessage":"MondrianInputErrorOnlyTabular","messagePattern":"MondrianInputErrorOnlyTabular","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"plugins/mondrianinput/impl/src/main/java/org/pentaho/di/trans/steps/mondrianinput/MondrianHelper.java","lineNumber":193,"sourceCode":"        if ( ( log != null ) && ( log.isDebug() ) ) {\n          log.logDebug( ignored.getMessage() );\n        }\n      }\n      connection = null;\n    }\n  }\n\n  /**\n   * Outputs one row per tuple on the rows axis.\n   *\n   * @throws KettleDatabaseException\n   *           in case some or other error occurs\n   */\n  public void createRectangularOutput() throws KettleDatabaseException {\n\n    final Axis[] axes = result.getAxes();\n    if ( axes.length != 2 ) {\n      throw new KettleDatabaseException( BaseMessages.getString( PKG, \"MondrianInputErrorOnlyTabular\" ) );\n    }\n    headings = new ArrayList<>();\n    rows = new ArrayList<>();\n\n    final Axis rowsAxis = axes[1];\n    final Axis columnsAxis = axes[0];\n\n    int rowOrdinal = -1;\n    int[] coords = { 0, 0 };\n    for ( Position rowPos : rowsAxis.getPositions() ) {\n      ++rowOrdinal;\n      coords[1] = rowOrdinal;\n      if ( rowOrdinal == 0 ) {\n        // Generate headings on the first row. Note that if there are\n        // zero rows, we don't have enough metadata to generate\n        // headings.\n\n        // First headings are for the members on the rows axis.","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/mondrianinput/impl/src/main/java/org/pentaho/di/trans/steps/mondrianinput/MondrianHelper.java#L175-L211","documentation":"MondrianHelper.createRectangularOutput() flattens an MDX result into rectangular headings/rows, which only works for a 2-axis (rows x columns) result. If the query's result has any number of axes other than 2, it throws KettleDatabaseException with the localized MondrianInputErrorOnlyTabular message. Used by MondrianInput's getFields and runtime output building.","triggerScenarios":"Executing an MDX query whose result has axes.length != 2 — e.g. a query with 0 axes (scalar cell), 1 axis, or 3+ axes — then calling createRectangularOutput (directly or via getFields).","commonSituations":"MDX queries using DRILLTHROUGH or single-value queries; OLAP cubes configured so the Mondrian result returns one axis; users writing MDX meant for raw tabular output instead of a cross-tab.","solutions":["Rewrite the MDX so it produces exactly two axes: a columns axis and a rows axis (e.g. SELECT ... ON COLUMNS, ... ON ROWS).","Avoid DRILLTHROUGH / single-cell queries in the Mondrian Input step; use a JDBC/relational step for tabular data instead.","Log result.getAxes().length during development to confirm the shape.","Check Mondrian schema/cube definitions if axis count is unexpectedly different."],"exampleFix":"// before: single axis query\nmdx = \"SELECT [Measures].[Sales] ON COLUMNS FROM Sales\";\n// after: two-axis (tabular) query\nmdx = \"SELECT [Measures].[Sales] ON COLUMNS, [Product].[Product].Members ON ROWS FROM Sales\";","handlingStrategy":"validation","validationCode":"// Inspect the MDX result shape before flattening\nResult result = olap4jConnection.createStatement().executeOlapQuery(mdx);\nif (result.getAxes().size() != 2) {\n  throw new IllegalStateException(\"MDX must return exactly 2 axes, got \" + result.getAxes().size());\n}","typeGuard":null,"tryCatchPattern":"try {\n  helper.createRectangularOutput();\n} catch (KettleDatabaseException e) {\n  logError(\"MDX result is not tabular (axes != 2): \" + e.getMessage(), e);\n}","preventionTips":["Always write MDX with explicit ON COLUMNS and ON ROWS axes","Avoid DRILLTHROUGH and scalar queries in Mondrian Input","Test the MDX in a query tool to confirm a 2-axis result"],"tags":["mdx","olap","kettle","mondrian"],"backgroundTag":"unexpected-response-shape","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"}