-
Notifications
You must be signed in to change notification settings - Fork 402
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
Negative indices on arrays seem to return nothing/null #240
Comments
I will take a look |
I'm not sure how this happened. There will be a patch to fix this shortly. |
Fix github issue #240 - negative array bounds. The issue was that the wrong variable name was used for the array index. It needed to be array_index, but was index instead. The reason this was not caught was - 1) There weren't any regression tests for this functionality. 2) The name 'index' was defined elsewhere as either a function or a struct. So, the compiler was okay with the particular usage. The variable name was changed to the correct name. Regression tests were added.
This has been corrected, and is available, in the master branch -
|
Thanks for the quick fix! |
Not sure if this is related, but seems very similar: select * from ag_catalog.cypher('g', $$ with {k0: [0, 1], k1: [2, 3]} as m return m.k0[1] $$) as (r0 ag_catalog.agtype);
-- r0
-- ----
-- 1
-- (1 row)
select * from ag_catalog.cypher('g', $$ with {k0: [0, 1], k1: [2, 3]} as m return m.k0[-1] $$) as (r0 ag_catalog.agtype);
-- r0
-- ----
--
-- (1 row)
select * from ag_catalog.cypher('g', $$ with {k0: [0, 1], k1: [2, 3]} as m return m.k0[-1..] $$) as (r0 ag_catalog.agtype);
-- ERROR: slice must access a list Note the second part, where the result is missing, and the third, which results in an error (while it likely should not). |
Nested arrays seem to have similar problems: select * from ag_catalog.cypher('g', $$ with [[0, 1], [2, 3]] as l return l[0][1] $$) as (r0 ag_catalog.agtype);
-- r0
-- ----
-- 1
-- (1 row)
select * from ag_catalog.cypher('g', $$ with [[0, 1], [2, 3]] as l return l[0][-1] $$) as (r0 ag_catalog.agtype);
-- r0
-- ----
--
-- (1 row)
select * from ag_catalog.cypher('g', $$ with [[0, 1], [2, 3]] as l return l[0][-1..] $$) as (r0 ag_catalog.agtype);
-- r0
-- ----------
-- [[0, 1]]
-- (1 row) Note the second part, where the result is missing, and the third, which doesn't seem to make sense. |
Yeah, it is in the same access operator functions. It is getting the wrong size of the returned array, since it is in a binary format. |
The other issue, with the slice operator, needs to be fixed as well. It was do to some inadvertent code changes. |
There is a pending patch to correct this. It should be applied within the next few days. |
Thanks. Feel free to close this ticket when that gets merged. |
Fix github issue apache#240 - negative array bounds. The issue was that the wrong variable name was used for the array index. It needed to be array_index, but was index instead. The reason this was not caught was - 1) There weren't any regression tests for this functionality. 2) The name 'index' was defined elsewhere as either a function or a struct. So, the compiler was okay with the particular usage. The variable name was changed to the correct name. Regression tests were added.
This reverts commit 0902deb.
Fixed github issue #240 - negative array bounds - addendum. There was found to be an issue with the transform_A_Indirection function. Previous work on the function removed a few important lines. This caused it to improperly transform nested indirections. These lines were added back in. Additionally, since the previous work on transform_A_Indirection, some new functionality was added to transform_ColumnRef. This allowed the removal of some unnecessary code as well. Added regression tests to cover nested access and slice operations.
The patch was applied and this should be corrected. If this fixes the problem for you, go ahead and close the ticket. It is preferred that those who open tickets close them when the issue is resolved. |
Yes, this fixes the issue. Thanks again. |
Fixed github issue apache#240 - negative array bounds - addendum. There was found to be an issue with the transform_A_Indirection function. Previous work on the function removed a few important lines. This caused it to improperly transform nested indirections. These lines were added back in. Additionally, since the previous work on transform_A_Indirection, some new functionality was added to transform_ColumnRef. This allowed the removal of some unnecessary code as well. Added regression tests to cover nested access and slice operations.
Describe the bug
Negative indices on arrays seem to return nothing/null.
How are you accessing AGE (Command line, driver, etc.)?
With
psql
from the docker image. One container for the server and another one for the client.What data setup do we need to do?
What is the necessary configuration info needed?
Just the docker image built from master branch.
What is the command that caused the error?
The above returns (note the empty line):
Compare with:
which return:
and:
Expected behavior
The negative index should work as described in: https://age.apache.org/docs/master/intro/types.html#negative-index-access
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: