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

I have a question about the function of the agtype json operator in version 1.5.0 #1521

Closed
shinhanbyeol opened this issue Jan 24, 2024 · 9 comments
Labels
question Further information is requested Stale Stale issues/PRs

Comments

@shinhanbyeol
Copy link
Contributor

i have a question about the phenomenon found in the version of age 1.5.0
The json operator function was fine in 1.4.0 as below query
select properties->'ott' from ott_service_1.ott_company;
image

However, starting with 1.5.0 and later versions
When you create a query, such as version 1.4.0
ERROR: invalid input syntax for type agtype error occurs, however
select properties-> 'ott'::text as ott_company_name from netflix_2.ott;
I did type casting like this, and the problem was solved.

image

Is this the phenomenon intended in 1.5.0? and Will this continue in future versions?

@shinhanbyeol shinhanbyeol added the question Further information is requested label Jan 24, 2024
@shinhanbyeol shinhanbyeol changed the title 1.5.0 버전에서의 agtype json operator 기능에 관한 질문이 있습니다 I have a question about the function of the agtype json operator in version 1.5.0 Jan 24, 2024
@jrgemignani
Copy link
Contributor

@shinhanbyeol What version of PG is this on, what version of PG did it previously work on?

@shinhanbyeol
Copy link
Contributor Author

@jrgemignani 1.5 ,1.4 Both were done in pg 14 version

@jrgemignani
Copy link
Contributor

@shinhanbyeol There appears to be something weird with the definition of ->
@Zainab-Saad Could you take a look?

@jrgemignani
Copy link
Contributor

psql-16.1-5432-pgsql=# select agtype_object_field(properties, 'name') from xyz._ag_label_vertex;
 agtype_object_field
---------------------
 "John"
(1 row)

psql-16.1-5432-pgsql=# select agtype_object_field_agtype(properties, 'name') from xyz._ag_label_vertex;
ERROR:  invalid input syntax for type agtype
LINE 1: select agtype_object_field_agtype(properties, 'name') from x...
                                                      ^
DETAIL:  Expected agtype value, but found "name".
CONTEXT:  agtype data, line 1: name
psql-16.1-5432-pgsql=#
psql-16.1-5432-pgsql=# select properties->'name' from xyz._ag_label_vertex;
ERROR:  invalid input syntax for type agtype
LINE 1: select properties->'name' from xyz._ag_label_vertex;
                           ^
DETAIL:  Expected agtype value, but found "name".
CONTEXT:  agtype data, line 1: name
psql-16.1-5432-pgsql=#

@Zainab-Saad
Copy link
Contributor

@shinhanbyeol There appears to be something weird with the definition of ->
@Zainab-Saad Could you take a look?

Yes, looking into this

@jrgemignani
Copy link
Contributor

@Zainab-Saad Thank you!

@Zainab-Saad
Copy link
Contributor

The error you are getting is because the operator -> is overloaded (in version 1.5.0) with the following possible operands
agtype -> agtype
agtype -> text
agtype -> int

In the query select properties->'ott' from ott_service_1.ott_company;, 'ott' is of the type unknown and when such a type is provided as second argument to the operator ->, postgres chooses the operator agtype -> agtype instead of agtype -> text. And 'ott' is not in valid agtype format (should be '"ott"'), so you get an error.

You can read why specific operator is choosen when unknown type is provided in the operator type resolution section here

Copy link

This issue is stale because it has been open 45 days with no activity. Remove "Abondoned" label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale Stale issues/PRs label May 11, 2024
Copy link

This issue was closed because it has been stalled for further 7 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale Stale issues/PRs
Projects
None yet
Development

No branches or pull requests

3 participants