You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "mihaibudiu (via GitHub)" <gi...@apache.org> on 2024/04/01 20:40:16 UTC
[PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
mihaibudiu opened a new pull request, #3748:
URL: https://github.com/apache/calcite/pull/3748
… negative indices
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3748:
URL: https://github.com/apache/calcite/pull/3748#issuecomment-2043719863
@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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3748:
URL: https://github.com/apache/calcite/pull/3748#discussion_r1548780522
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -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)",
Review Comment:
Thank you for your reply
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3748:
URL: https://github.com/apache/calcite/pull/3748#discussion_r1548088300
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -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)",
+ "[1, 3, 4, 2]", "INTEGER NOT NULL ARRAY NOT NULL");
+ f1.checkScalar("array_insert(array[1, 3, 4], -3, 2)",
"[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)",
Review Comment:
Maybe we should write array(), spark does not allow array[]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3748:
URL: https://github.com/apache/calcite/pull/3748#discussion_r1548086199
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -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)",
Review Comment:
@mihaibudiu Hello!
array_insert(array(1, 3, 4), -4, 2) Spark seems to allow this situation, should we add some test samples?

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "chucheng92 (via GitHub)" <gi...@apache.org>.
chucheng92 commented on PR #3748:
URL: https://github.com/apache/calcite/pull/3748#issuecomment-2044226210
looks good to me. thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3748:
URL: https://github.com/apache/calcite/pull/3748#discussion_r1548173980
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -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)",
+ "[1, 3, 4, 2]", "INTEGER NOT NULL ARRAY NOT NULL");
+ f1.checkScalar("array_insert(array[1, 3, 4], -3, 2)",
"[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)",
Review Comment:
these two forms are equivalent
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #3748:
URL: https://github.com/apache/calcite/pull/3748
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3748:
URL: https://github.com/apache/calcite/pull/3748#discussion_r1548780666
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -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)",
+ "[1, 3, 4, 2]", "INTEGER NOT NULL ARRAY NOT NULL");
+ f1.checkScalar("array_insert(array[1, 3, 4], -3, 2)",
"[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)",
Review Comment:
thank you for your reply
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3748:
URL: https://github.com/apache/calcite/pull/3748#discussion_r1548173623
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -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)",
Review Comment:
the docs say that this is a prepend. there is a test for this below
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3748:
URL: https://github.com/apache/calcite/pull/3748#discussion_r1548076355
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -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)",
Review Comment:
I have a question, what will happen if the array length is 5, but I fill in -6? I can test it in spark
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6285] Function ARRAY_INSERT produces an incorrect result for… [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3748:
URL: https://github.com/apache/calcite/pull/3748#discussion_r1548086199
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -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)",
Review Comment:
@mihaibudiu Hello!
array_insert(array(1, 3, 4), -4, 2) Spark seems to allow this situation, should we add some test samples?

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org