-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. thank you for your reply |
||
"[1, null, 2, 3, null, 4]", "INTEGER ARRAY NOT NULL"); | ||
// check complex type | ||
f1.checkScalar("array_insert(array[array[1,2]], 1, array[1])", | ||
"[[1], [1, 2]]", "INTEGER NOT NULL ARRAY NOT NULL ARRAY NOT NULL"); | ||
f1.checkScalar("array_insert(array[array[1,2]], -1, array[1])", | ||
"[[1], [1, 2]]", "INTEGER NOT NULL ARRAY NOT NULL ARRAY NOT NULL"); | ||
"[[1, 2], [1]]", "INTEGER NOT NULL ARRAY NOT NULL ARRAY NOT NULL"); | ||
f1.checkScalar("array_insert(array[map[1, 'a']], 1, map[2, 'b'])", "[{2=b}, {1=a}]", | ||
"(INTEGER NOT NULL, CHAR(1) NOT NULL) MAP NOT NULL ARRAY NOT NULL"); | ||
f1.checkScalar("array_insert(array[map[1, 'a']], -1, map[2, 'b'])", "[{2=b}, {1=a}]", | ||
f1.checkScalar("array_insert(array[map[1, 'a']], -1, map[2, 'b'])", "[{1=a}, {2=b}]", | ||
"(INTEGER NOT NULL, CHAR(1) NOT NULL) MAP NOT NULL ARRAY NOT NULL"); | ||
|
||
// element cast to the biggest type | ||
|
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