{"record":{"id":"9966468815df752c","repo":"databendlabs/databend","slug":"point-geometry-996646","errorCode":null,"errorMessage":"point geometry","messagePattern":"point geometry","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/expression/src/geographic/overlay.rs","lineNumber":148,"sourceCode":"        Self::is_single_geometry(g0) && Self::is_single_geometry(g1)\n    }\n\n    fn is_single_geometry(geom: &Geometry<f64>) -> bool {\n        matches!(\n            geom,\n            Geometry::Point(_) | Geometry::LineString(_) | Geometry::Polygon(_)\n        )\n    }\n\n    fn build_geometry_from_elements(elements: Vec<Geometry<f64>>) -> Option<Geometry<f64>> {\n        if elements.is_empty() {\n            return None;\n        }\n\n        if elements.iter().all(|geo| matches!(geo, Geometry::Point(_))) {\n            let points: Vec<Point<f64>> = elements\n                .into_iter()\n                .map(|geo| geo.try_into().expect(\"point geometry\"))\n                .collect();\n            return Some(Geometry::MultiPoint(MultiPoint::from_iter(points)));\n        }\n\n        if elements\n            .iter()\n            .all(|geo| matches!(geo, Geometry::LineString(_)))\n        {\n            let lines: Vec<LineString<f64>> = elements\n                .into_iter()\n                .map(|geo| geo.try_into().expect(\"linestring geometry\"))\n                .collect();\n            return Some(Geometry::MultiLineString(MultiLineString::from_iter(lines)));\n        }\n\n        if elements\n            .iter()\n            .all(|geo| matches!(geo, Geometry::Polygon(_)))","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/expression/src/geographic/overlay.rs#L130-L166","documentation":"In geographic overlay's `build_geometry_from_elements`, when all overlay elements are `Geometry::Point(_)`, each is converted to `Point<f64>` via `try_into().expect(\"point geometry\")` to construct a MultiPoint. The expect asserts that the conversion cannot fail after the type guard; a panic means the Point TryFrom impl failed on a guarded value, an internal invariant break.","triggerScenarios":"Overlay operations (intersection/union) whose result elements are all points, but where the `TryFrom<Geometry> for Point<f64>` conversion returns Err — e.g. points with invalid coordinates produced by the overlay computation.","commonSituations":"Overlaying nearly-coincident geometries producing degenerate points; geo crate version changes; numeric precision artifacts yielding invalid coordinates.","solutions":["Inspect overlay output for degenerate/NaN point coordinates.","Verify the geo crate Point TryFrom impl behavior for the pinned version.","Downgrade the expect to returning `None` (matching the function's Option-based contract) on conversion failure."],"exampleFix":"// before\n.map(|geo| geo.try_into().expect(\"point geometry\"))\n// after\n.map(|geo| geo.try_into().ok())\n.collect::<Option<Vec<_>>>()?;","handlingStrategy":"validation","validationCode":"// before overlay:\nlet valid = geoms.iter().all(|g| matches!(g, Geometry::Point(p) if p.x().is_finite() && p.y().is_finite()));\nif !valid { return Err(/* reject degenerate points */); }","typeGuard":"fn is_finite_point(g: &Geometry) -> bool { matches!(g, Geometry::Point(p) if p.x().is_finite() && p.y().is_finite()) }","tryCatchPattern":"let result = std::panic::catch_unwind(|| overlay(geoms.clone()));","preventionTips":["Check overlay inputs for near-coincident geometry that may produce degenerate points.","Pin geo crate versions and rerun geographic tests on upgrades.","Sanitize coordinates for finiteness before overlay operations."],"tags":["rust","geospatial","overlay"],"backgroundTag":"internal-invariant-violation","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"}