{"record":{"id":"b7890d74243bb5d9","repo":"databendlabs/databend","slug":"invalid-join-type-during-building-physical-hash","errorCode":null,"errorMessage":"Invalid join type {} during building physical hash join.","messagePattern":"Invalid join type (.+?) during building physical hash join\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/service/src/physical_plans/physical_hash_join.rs","lineNumber":1158,"sourceCode":"                    DataType::Nullable(Box::new(DataType::Boolean)),\n                ));\n                result\n            }\n            JoinType::RightMark => {\n                let name = if let Some(idx) = join.marker_index {\n                    idx.to_string()\n                } else {\n                    \"marker\".to_string()\n                };\n                let mut result = probe_fields;\n                result.push(DataField::new(\n                    name.as_str(),\n                    DataType::Nullable(Box::new(DataType::Boolean)),\n                ));\n                result\n            }\n            JoinType::Asof | JoinType::LeftAsof | JoinType::RightAsof | JoinType::FullAsof => {\n                unreachable!(\n                    \"Invalid join type {} during building physical hash join.\",\n                    join.join_type\n                )\n            }\n        };\n\n        // Create projections and output schema\n        let mut projections = BTreeSet::new();\n        let projected_schema = DataSchema::new(merged_fields.clone());\n\n        for column in column_projections.iter() {\n            if let Some((index, _)) = projected_schema.column_with_name(&column.to_string()) {\n                projections.insert(index);\n            }\n        }\n\n        let mut output_fields = Vec::with_capacity(column_projections.len());\n        for (i, field) in merged_fields.iter().enumerate() {","sourceCodeStart":1140,"sourceCodeEnd":1176,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/service/src/physical_plans/physical_hash_join.rs#L1140-L1176","documentation":"create_output_schema computes the output schema for a physical hash join and supports all regular join types, but ASOF joins (Asof/LeftAsof/RightAsof/FullAsof) are implemented by a dedicated ASOF join operator. Encountering an ASOF type here means a hash join was built for a join that must use the ASOF path, so the code panics via unreachable!.","triggerScenarios":"build_hash_join is invoked for a join whose JoinType is Asof, LeftAsof, RightAsof, or FullAsof — i.e. the physical planner dispatched an ASOF join to the hash-join builder.","commonSituations":"Writing ASOF JOIN queries and hitting a planner dispatch bug; optimizer rule changes that reroute ASOF joins into hash join construction; version regressions in join planning.","solutions":["Check the query's join type and planner dispatch; ensure ASOF joins route to the ASOF physical join builder.","Upgrade to a version where ASOF joins are dispatched correctly.","Rewrite the query without ASOF JOIN (use a subquery with ORDER BY/LIMIT per key) as a workaround.","File a bug with the query and EXPLAIN plan showing the ASOF join reaching hash join build."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"-- Confirm the join type dispatch before physical planning\n-- ASOF joins must route to the ASOF builder, not hash join\nEXPLAIN ASOF JOIN ...; -- inspect the physical plan nodes","typeGuard":"fn needs_asof_builder(jt: &JoinType) -> bool {\n    matches!(jt, JoinType::Asof | JoinType::LeftAsof | JoinType::RightAsof | JoinType::FullAsof)\n}","tryCatchPattern":null,"preventionTips":["Add dispatch tests: every JoinType must route to its correct physical builder","Extend the dispatcher (not the hash join) when adding new join types","Run ASOF JOIN query suites in CI after planner changes"],"tags":["rust","join","asof","planner"],"backgroundTag":"invalid-enum-value","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}