postgrespro / pgsphere

PgSphere provides spherical data types, functions, operators, and indexing for PostgreSQL.
https://pgsphere.org
BSD 3-Clause "New" or "Revised" License
16 stars 15 forks source link

CREATE INDEX error... Missing strans comparison function or hash opclass? #93

Open esabol opened 8 months ago

esabol commented 8 months ago

One of my colleagues is trying to create an index on a column operated on with a PL/pgsql function that we have that uses various pgsphere types and operators and received this error....

> create index xgeom_s_region on sometable ((xgeom_intext(s_region)))
ERROR: could not identify a comparison function for type strans

Should pgsphere provide a comparison function for strans objects? Does that even make sense?

In the meantime, if anyone has even a quick and dirty solution or advice to help my colleague get beyond this error, please reply.

vitcpp commented 8 months ago

@esabol I would propose to share some information about xgeom_intext function and s_region type.

df7cb commented 8 months ago

I'm getting a different error here:

create table s (s strans);
create index on s(s);
ERROR:  42704: data type strans has no default operator class for access method "btree"
HINT:  You must specify an operator class for the index or define a default operator class for the data type.

Looking up strans by actual value in a btree doesn't seem to make much sense to me. Wouldn't you rather look up the transformation by some other means and then apply it?

esabol commented 8 months ago

I would propose to share some information about xgeom_intext function and s_region type.

s_region isn't a type. It's a text column in the table that contains strings like "CIRCLE('ICRS',0,0,1)".

xgeom_intext is a complicated PLpgsql function that basically takes strings like that and converts them into pgsphere objects.

df7cb commented 8 months ago

What operation inside the xgeom_intext function is triggering that error?

esabol commented 8 months ago

What operation inside the xgeom_intext function is triggering that error?

I don't know!

df7cb commented 8 months ago

Does select xgeom_intext(s_region) from xgeom_s_region; throw the same error, perhaps with more detail?

esabol commented 8 months ago

xgeom_s_region is the name of the index.select xgeom_intext(s_region) from sometable does not throw any errors. This error only occurs when you try to create an index on it.

df7cb commented 8 months ago

esabol wrote in #101:

I wonder if the error in issue #93 would be helped if there was a hash opclass for strans?

Could be, but more likely a btree opclass since you are building a btree index.

What datatype does xgeom_intext return?

esabol commented 8 months ago

@df7cb asked:

Could be, but more likely a btree opclass since you are building a btree index.

Ah, yeah, that makes sense.

What datatype does xgeom_intext return?

A user-defined type we call "xgeom". strans is a component, but also spoint and scircle and possibly spoly (but not really in practice). It's kind of a generic spherical geometry polymorphic type.

df7cb commented 8 months ago

The strans error message might go away when we implement a btree opclass, but what would strans < strans even mean? If you only want equality lookups, a hash opclass would make more sense.