databendlabs/databend · error

point geometry

Error message

point geometry

What it means

In the geographic aggregate `compute`, after verifying every geometry matches `Geometry::Point(_)`, each geometry is converted with `try_into::<Point<f64>>` and the result is unwrapped with `expect("point geometry")`. The guard makes the conversion infallible in theory; the panic fires only if the Point→point conversion impl itself fails, indicating a bug in the TryFrom implementation or a corrupted geometry value. It is an internal invariant assertion, not user-facing input validation.

Solutions

  1. Inspect the geometries feeding the aggregate for degenerate coordinates (NaN, empty) that the Point TryFrom impl rejects.
  2. Verify geo crate version compatibility of the `TryFrom<Geometry> for Point<f64>` impl.
  3. If a legitimate non-convertible case exists, replace the expect with error propagation (`?` into the surrounding `Ok` result).

Example fix

// before
.map(|geo| geo.try_into().expect("point geometry"))
// after
.map(|geo| geo.try_into().map_err(|e| ErrorCode::BadArguments(format!("point geometry: {e}"))))
.collect::<Result<Vec<_>, _>>()?;
Defensive patterns

Strategy: validation

Validate before calling

// caller-side check before aggregating:
let all_valid_points = geos.iter().all(|g| matches!(g, Geometry::Point(p) if p.x().is_finite() && p.y().is_finite()));

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

// panics are not catchable in stable Rust without catch_unwind:
let result = std::panic::catch_unwind(|| aggregate_points(geos.clone()));

Prevention

When it happens

Trigger: Running a geographic aggregate (e.g. ST_ASTEXT-style aggregation of points) over values where the guarded `Geometry::Point(_)` branch executes but the `TryFrom<Geometry> for Point<f64>` conversion returns Err — e.g. a Point carrying invalid/empty coordinate data the converter rejects.

Common situations: Feeding degenerate or NaN-coordinate points into geometry aggregation; a geo crate version change altering conversion semantics; corrupted geometry values from deserialization.

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/7920c27e353887e3. Report an issue: GitHub.

Appendix: source

Thrown at src/query/expression/src/geographic/aggregate.rs:93

        apply_geometry_overlay(geos, OverlayMode::SymDifference)
    }
    fn binary_compute(l_geo: Geometry<f64>, r_geo: Geometry<f64>) -> Result<Option<Geometry<f64>>> {
        apply_binary_geometry_overlay(l_geo, r_geo, OverlayMode::SymDifference)
    }
}

pub struct CollectAggOp;

impl GeoAggOp for CollectAggOp {
    fn compute(geos: Vec<Geometry<f64>>) -> Result<Option<Geometry<f64>>> {
        if geos.is_empty() {
            return Ok(None);
        }

        if geos.iter().all(|geo| matches!(geo, Geometry::Point(_))) {
            let points: Vec<Point<f64>> = geos
                .into_iter()
                .map(|geo| geo.try_into().expect("point geometry"))
                .collect();
            let multi_point = MultiPoint::from_iter(points);
            return Ok(Some(Geometry::MultiPoint(multi_point)));
        }
        if geos
            .iter()
            .all(|geo| matches!(geo, Geometry::LineString(_)))
        {
            let lines: Vec<LineString<f64>> = geos
                .into_iter()
                .map(|geo| geo.try_into().expect("linestring geometry"))
                .collect();
            let multi_line_string = MultiLineString::from_iter(lines);
            return Ok(Some(Geometry::MultiLineString(multi_line_string)));
        }
        if geos.iter().all(|geo| matches!(geo, Geometry::Polygon(_))) {
            let polygons: Vec<Polygon<f64>> = geos
                .into_iter()

View on GitHub (pinned to 288d84d76e)