cube-js/cube · error

Unsupported node type: {:?}

Error message

Unsupported node type: {:?}

What it means

In the same converter, any LogicalPlan::Expr node type not handled by the preceding match arms in add_expr_replace_params reaches the catch-all unimplemented!("Unsupported node type: {:?}") and panics with the debug dump of the expression. This marks expression kinds the CubeSQL rewrite/conversion layer (with parameter replacement) does not support.

Source

Thrown at rust/cubesql/cubesql/src/compile/rewrite/converter.rs:575

                        add_expr_data_node!(graph, GroupingSetType::Rollup, GroupingSetExprType);
                    graph.add(LogicalPlanLanguage::GroupingSetExpr([members, expr_type]))
                }
                GroupingSet::Cube(members) => {
                    let members = add_binary_expr_list_node!(
                        graph,
                        members,
                        query_params,
                        GroupingSetExprMembers,
                        false
                    );
                    let expr_type =
                        add_expr_data_node!(graph, GroupingSetType::Cube, GroupingSetExprType);
                    graph.add(LogicalPlanLanguage::GroupingSetExpr([members, expr_type]))
                }
                _ => unimplemented!("Unsupported grouping set type: {:?}", expr),
            },
            // TODO: Support all
            _ => unimplemented!("Unsupported node type: {:?}", expr),
        })
    }

    pub fn add_logical_plan(&mut self, plan: &LogicalPlan) -> Result<Id, CubeError> {
        self.add_logical_plan_replace_params(
            plan,
            &mut None,
            &LogicalPlanToLanguageContext::default(),
        )
    }

    pub fn add_logical_plan_replace_params(
        &mut self,
        plan: &LogicalPlan,
        query_params: &mut Option<HashMap<usize, ScalarValue>>,
        ctx: &LogicalPlanToLanguageContext,
    ) -> Result<Id, CubeError> {
        Ok(match plan {

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Rewrite the query using simpler/supported expression forms that the converter handles
  2. Upgrade Cube so the converter covers the expression type, or add a match arm for the printed expression in rust/cubesql/cubesql/src/compile/rewrite/converter.rs:575
  3. Try the Tesseract SQL planner (CUBEJS_TESSERACT_SQL_PLANNER=true) which does not use this legacy converter path

Example fix

// before
_ => unimplemented!("Unsupported node type: {:?}", expr),
// after
other => Err(CubeError::internal(format!(
    "Unsupported expression node in query rewrite: {:?}; simplify the query or add converter support",
    other
))),
Defensive patterns

Strategy: try-catch

Validate before calling

// Fail fast on exotic SQL constructs the legacy converter does not support
const unsupported = [/\bFILTER\s*\(/i, /\bWITHIN\s+GROUP/i, /OVER\s*\(.*\bROWS\s+BETWEEN/i];
if (unsupported.some(re => re.test(sql))) {
  throw new Error('Query uses constructs unsupported by the CubeSQL converter; simplify or use Tesseract planner');
}

Type guard

function usesOnlySupportedExprs(sql, supportedPatterns = [/^SELECT/i, /\bSUM\(/i, /\bCOUNT\(/i, /\bAVG\(/i]) {
  return supportedPatterns.some(re => re.test(sql)) && !/\bFILTER\s*\(/i.test(sql);
}

Try / catch

try {
  return await connection.query(sql);
} catch (e) {
  if (/Unsupported node type/i.test(String(e.message))) {
    console.error('CubeSQL converter rejected expression; simplify query or switch planner', e.message);
    return await connection.query(simplify(sql));
  }
  throw e;
}

Prevention

When it happens

Trigger: Compiling a SQL query whose plan contains an expression node type missing from add_expr_replace_params' match (e.g. newer DataFusion expression variants, unsupported window/aggregate/between forms) while the plan is being converted with replace-params semantics.

Common situations: Using advanced SQL constructs (window frames, exotic operators, newly added DataFusion expressions) through Cube's SQL API; version upgrades where DataFusion expression enums grew and the converter wasn't updated.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/78ed3aba6aa1cb25. Report an issue: GitHub.