Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
esabol opened this issue Oct 26, 2023 · 10 comments
Open

Comments

@esabol
Copy link
Contributor

esabol commented Oct 26, 2023

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
Copy link
Contributor

vitcpp commented Oct 27, 2023

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

@df7cb
Copy link
Contributor

df7cb commented Oct 27, 2023

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
Copy link
Contributor Author

esabol commented Oct 27, 2023

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
Copy link
Contributor

df7cb commented Oct 27, 2023

What operation inside the xgeom_intext function is triggering that error?

@esabol
Copy link
Contributor Author

esabol commented Oct 27, 2023

What operation inside the xgeom_intext function is triggering that error?

I don't know!

@df7cb
Copy link
Contributor

df7cb commented Oct 27, 2023

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

@esabol
Copy link
Contributor Author

esabol commented Oct 27, 2023

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
Copy link
Contributor

df7cb commented Nov 4, 2023

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
Copy link
Contributor Author

esabol commented Nov 4, 2023

@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
Copy link
Contributor

df7cb commented Nov 4, 2023

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.

@esabol esabol changed the title Missing strans comparison function? Missing strans comparison function or btree opclass? Mar 19, 2024
@esabol esabol changed the title Missing strans comparison function or btree opclass? Missing strans comparison function or hash opclass? May 16, 2024
@esabol esabol changed the title Missing strans comparison function or hash opclass? CREATE INDEX error... Missing strans comparison function or hash opclass? May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants