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
[CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… #3748
Conversation
… negative indices Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -7008,18 +7008,20 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { | |||
"[1, 2, null, 3]", "INTEGER ARRAY NOT NULL"); | |||
f1.checkScalar("array_insert(array[2, 3, 4], 1, 1)", | |||
"[1, 2, 3, 4]", "INTEGER NOT NULL ARRAY NOT NULL"); | |||
f1.checkScalar("array_insert(array[1, 3, 4], -2, 2)", | |||
f1.checkScalar("array_insert(array[1, 3, 4], -1, 2)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question, what will happen if the array length is 5, but I fill in -6? I can test it in spark
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mihaibudiu Hello!
array_insert(array(1, 3, 4), -4, 2) Spark seems to allow this situation, should we add some test samples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the docs say that this is a prepend. there is a test for this below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your reply
"[1, 2, 3, 4]", "INTEGER NOT NULL ARRAY NOT NULL"); | ||
f1.checkScalar("array_insert(array[2, 3, null, 4], -5, 1)", | ||
f1.checkScalar("array_insert(array[2, 3, null, 4], -6, 1)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should write array(), spark does not allow array[]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two forms are equivalent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for your reply
@chucheng92 I think we agreed to follow the semantics from the newest version of spark, so if you have no objection I will merge this PR. |
looks good to me. thanks. |
… negative indices