{"record":{"id":"6ef1e52968bef081","repo":"risingwavelabs/risingwave","slug":"generating-plan-error-0","errorCode":null,"errorMessage":"Generating plan error: {0}","messagePattern":"Generating plan error: (.+?)","errorType":"error_code","errorClass":"GenDataFusionPlanError","httpStatus":null,"severity":"error","filePath":"src/frontend/src/datafusion/execute/mod.rs","lineNumber":66,"sourceCode":"mod query_planner;\n\npub(crate) use memory_ctx::create_df_spillable_budget_ctx;\nconst DF_MANAGED_SPILL_DIR: &str = \"df_batch_spill/\";\n\n#[derive(Clone)]\npub struct DfBatchQueryPlanResult {\n    pub(crate) plan: Arc<LogicalPlan>,\n    pub(crate) schema: RwSchema,\n    pub(crate) stmt_type: StatementType,\n}\n\n#[derive(Debug, Error)]\npub enum GenDataFusionPlanError {\n    #[error(\"Missing Iceberg Scan\")]\n    MissingIcebergScan,\n    #[error(\"Unsupported Plan Node\")]\n    UnsupportedPlanNode,\n    #[error(\"Generating plan error: {0}\")]\n    Generating(#[source] RwError),\n}\n\npub fn try_gen_datafusion_plan(\n    optimized_logical: &BatchOptimizedLogicalPlanRoot,\n) -> Result<Arc<LogicalPlan>, GenDataFusionPlanError> {\n    use crate::optimizer::DataFusionExecuteCheckerExt;\n\n    let check_result = optimized_logical.plan.check_for_datafusion();\n    if !check_result.have_iceberg_scan {\n        return Err(GenDataFusionPlanError::MissingIcebergScan);\n    }\n    if !check_result.supported {\n        return Err(GenDataFusionPlanError::UnsupportedPlanNode);\n    }\n\n    let plan = optimized_logical\n        .gen_datafusion_logical_plan()","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/datafusion/execute/mod.rs#L48-L84","documentation":"The `Generating` variant of `GenDataFusionPlanError` wraps an underlying `RwError` produced while building the DataFusion `LogicalPlan` (e.g. schema/type conversion failures when mapping RisingWave fields to Arrow/DataFusion types). The message prefixes the wrapped error's display text.","triggerScenarios":"Any failure inside DataFusion plan construction during `try_gen_datafusion_plan`: unsupported RisingWave data types with no Arrow equivalent, invalid expression translation, or DataFusion API errors while registering scans/projections.","commonSituations":"Iceberg tables with column types not representable in the expected Arrow/DataFusion schema; expression pushdown of functions DataFusion does not implement; version drift between the DataFusion dependency and the translation code.","solutions":["Inspect the wrapped source error (`RwError`) for the root cause and fix accordingly.","Check for unsupported column/expression types in the query and cast them to supported types.","Align the DataFusion dependency version with what the translation code expects."],"exampleFix":"-- before\nSELECT * FROM iceberg_tbl WHERE exotic_udb_col > 1; -- type fails DataFusion translation\n-- after\nSELECT * FROM iceberg_tbl WHERE CAST(exotic_col AS DOUBLE) > 1.0;","handlingStrategy":"try-catch","validationCode":"// pre-check column types are Arrow-representable before generating the plan\nconst bad = cols.filter(c => !ARROW_SUPPORTED_TYPES.has(c.type));\nif (bad.length) throw new Error(\"columns unsupported by DataFusion: \" + bad.map(c => c.name));","typeGuard":"function isArrowRepresentable(rwType) { return ARROW_SUPPORTED_TYPES.has(rwType); }","tryCatchPattern":"match try_gen_datafusion_plan(&plan) {\n    Err(GenDataFusionPlanError::Generating(src)) => {\n        log::error!(\"datafusion plan generation failed: {src}\"); // inspect wrapped RwError\n    }\n    r => r?,\n}","preventionTips":["Log/inspect the wrapped #[source] RwError — it contains the real cause","Cast exotic column types to supported types before querying via the DataFusion path","Keep the DataFusion dependency version compatible with the translation code"],"tags":["datafusion","iceberg","query-planning","error-wrapping"],"backgroundTag":"sql-query-failed","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}