Skip to content

bug(python): Error during planning: Invalid function 'st_dwithin'. - trying to use ST_DWithin filter #3109

Closed

Description

@abgros

LanceDB version

2.0.1

What happened?

I tried adapting the code from this blog post: https://lancedb.com/blog/geo-support/.

The blog post uses a ST_DWithin filter to find rows within a certain distance of the given point.

However, I tried using ST_DWithin in my own code and appears to not be implemented.

Are there known steps to reproduce?

Reproducer script:

import tempfile
import numpy as np
import lance
import pyarrow as pa
from geoarrow.rust.core import point, points

geo_arr = points([np.array([-119.3]), np.array([63.7])])
schema = pa.schema([pa.field(point("xy")).with_name("geometry")])
table = pa.Table.from_arrays([geo_arr], schema=schema)

with tempfile.TemporaryDirectory() as tmp:
    ds = lance.write_dataset(table, f"{tmp}/test.lance")
    print(ds.schema)
    ds.scanner(
        filter="ST_DWithin(geometry, ST_Point(-119.3, 63.7), 1000)",
        prefilter=True,
    ).to_table()

Output:

geometry: struct<x: double not null, y: double not null>
  child 0, x: double not null
  child 1, y: double not null
  -- field metadata --
  ARROW:extension:name: 'geoarrow.point'
Traceback (most recent call last):
  File "/home/azureuser/Database-Maintenance/python-code/repro_geo.py", line 17, in <module>
    ).to_table()
      ~~~~~~~~^^
  File "/home/azureuser/Database-Maintenance/python-code/.venv/lib/python3.14/site-packages/lance/dataset.py", line 5135, in to_table
    return self.to_reader().read_all()
           ~~~~~~~~~~~~~~^^
  File "/home/azureuser/Database-Maintenance/python-code/.venv/lib/python3.14/site-packages/lance/dataset.py", line 5138, in to_reader
    return self._scanner.to_pyarrow()
           ~~~~~~~~~~~~~~~~~~~~~~~~^^
ValueError: Invalid user input: Error parsing function: Error during planning: Invalid function 'st_dwithin'.
Did you mean 'st_within'?, /home/runner/work/lance/lance/rust/lance-datafusion/src/planner.rs:466:87

Activity

  1. added
    bug
    on Mar 5, 2026
  2. camilesing commented on Mar 9, 2026

    @camilesing

    Hi @abgros , by the blog description, the demo was created from developer branch. Demo repo is: https://github.com/ddupg/lance-geo-test/blob/main/src/main.rs, lance dependecy info is lance = { git = "https://github.com/ddupg/lance", branch = "sx/upgrade-arrow-datafusion" }

  3. Xuanwo commented on Aug 6, 2026

    @Xuanwo
    Member

    Hi, this issue is invalid because ST_DWithin is not implemented in released LanceDB (the geo feature is disabled and GeoDataFusion does not expose the function); the blog demo was built on a developer branch, so this is a feature request rather than a bug. I'm closing this now. Feel free to create a new issue if the problem still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions