databendlabs/databend · error
point geometry
Error message
point geometry
What it means
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.
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.
Example fix
// before
.map(|geo| geo.try_into().expect("point geometry"))
// after
.map(|geo| geo.try_into().ok())
.collect::<Option<Vec<_>>>()?; Defensive patterns
Strategy: validation
Validate before calling
// before overlay:
let valid = geoms.iter().all(|g| matches!(g, Geometry::Point(p) if p.x().is_finite() && p.y().is_finite()));
if !valid { return Err(/* reject degenerate points */); } Type guard
fn is_finite_point(g: &Geometry) -> bool { matches!(g, Geometry::Point(p) if p.x().is_finite() && p.y().is_finite()) } Try / catch
let result = std::panic::catch_unwind(|| overlay(geoms.clone()));
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Overlaying nearly-coincident geometries producing degenerate points; geo crate version changes; numeric precision artifacts yielding invalid coordinates.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/9966468815df752c.
Report an issue: GitHub.
Appendix: source
Thrown at src/query/expression/src/geographic/overlay.rs:148
Self::is_single_geometry(g0) && Self::is_single_geometry(g1)
}
fn is_single_geometry(geom: &Geometry<f64>) -> bool {
matches!(
geom,
Geometry::Point(_) | Geometry::LineString(_) | Geometry::Polygon(_)
)
}
fn build_geometry_from_elements(elements: Vec<Geometry<f64>>) -> Option<Geometry<f64>> {
if elements.is_empty() {
return None;
}
if elements.iter().all(|geo| matches!(geo, Geometry::Point(_))) {
let points: Vec<Point<f64>> = elements
.into_iter()
.map(|geo| geo.try_into().expect("point geometry"))
.collect();
return Some(Geometry::MultiPoint(MultiPoint::from_iter(points)));
}
if elements
.iter()
.all(|geo| matches!(geo, Geometry::LineString(_)))
{
let lines: Vec<LineString<f64>> = elements
.into_iter()
.map(|geo| geo.try_into().expect("linestring geometry"))
.collect();
return Some(Geometry::MultiLineString(MultiLineString::from_iter(lines)));
}
if elements
.iter()
.all(|geo| matches!(geo, Geometry::Polygon(_)))View on GitHub (pinned to 288d84d76e)