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

[CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… #3748

Merged
merged 1 commit into from Apr 9, 2024

Conversation

mihaibudiu
Copy link
Contributor

… negative indices

… negative indices

Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
Copy link
Member

@caicancai caicancai left a 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)",
Copy link
Member

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

Copy link
Member

@caicancai caicancai Apr 2, 2024

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?

2024-04-02 23-10-05屏幕截图

Copy link
Contributor Author

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

Copy link
Member

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)",
Copy link
Member

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[]

Copy link
Contributor Author

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

Copy link
Member

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

@mihaibudiu
Copy link
Contributor Author

@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.

@mihaibudiu mihaibudiu added the LGTM-will-merge-soon Overall PR looks OK. Only minor things left. label Apr 8, 2024
@chucheng92
Copy link
Member

looks good to me. thanks.

@mihaibudiu mihaibudiu merged commit 9bd3713 into apache:main Apr 9, 2024
29 of 30 checks passed
@mihaibudiu mihaibudiu deleted the issue6285 branch April 9, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LGTM-will-merge-soon Overall PR looks OK. Only minor things left.
Projects
None yet
3 participants