stefanoa0

stefanoa0

Hello everyone, I hope you are well.

I’m migrating from PostgreSQL to CockroachDB and everything was going well until I came across the following error using the Geo.Postgis lib:

** (Postgrex.Error) ERROR 42883 (undefined_function) st_contains(): unknown signature: st_buffer(geometry, geometry) (desired <geometry>)

Here is the specific where snippet:

|> where(
      [u],
      st_contains(st_buffer(st_set_srid(st_make_point(^lng, ^lat), 4326), ^distance), u.geo_point)
    )

I tried changing to a fragment function with the string:

fragment("ST_Contains(ST_Buffer(ST_SetSRID(ST_MakePoint($2, $3), 4326), $4), u0.geo_point)", lng, lat, distance)

But the same error happened

Has anyone had a similar error?

Thanks for your time!

Marked As Solved

stefanoa0

stefanoa0 OP

Hello

Thanks for this informations, but the CockroachDB is compatible with PostgresSQL, as described:

[> CockroachDB supports the PostgreSQL wire protocol and the majority of PostgreSQL syntax. This means that existing applications built on PostgreSQL can often be migrated to CockroachDB without changing application code.]

So, the migrations was easy and all the queries are running very well, but that query who uses the Postgis functions needed to changed, I had to cast the distance to float and It’s works!

|> where(
      [u],
      st_contains(st_buffer(st_set_srid(st_make_point(^lng, ^lat), 4326), ^fragment("Cast(? as FLOAT)", distance), u.geo_point)
    )

So, thanks for your help and time!

Also Liked

pdgonzalez872

pdgonzalez872

hi @stefanoa0 , welcome to ElixirForum!

So, ST_Contains is not native to Postgres, it comes from the postgis extension. You can use the function when you install an extension. Here is the documentation for the function: https://postgis.net/docs/manual-3.4/ST_Contains.html.

The lib you are using is a wrapper around the postgis extension, that’s why your fragment didn’t work. Postgres just doesn’t know a function with that name.

Here is a link that will help you migrate that specific functionality over: How we built scalable spatial data and spatial indexing in CockroachDB

I love Postgres, including the postgis library. Sad to see you migrate away from Postgres, but good luck nonetheless!

pdgonzalez872

pdgonzalez872

Great!

Thanks for this informations, but the CockroachDB is compatible with PostgresSQL, as described:

Well, we saw that in this case it wasn’t a 1 to 1 since you had to refactor that function call. BUT, on CockRoachDB’s defense, postgis is not part of core, it’s an extension to Postgres even though it is the de-facto way of dealing with spacial data in Postgres. So, their claim could still very well be valid.

So, thanks for your help and time!

You are welcome!

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews