Skip to content

Commit

Permalink
[bug](function) fix array_apply function return wrong result (apache#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Dec 15, 2023
1 parent bde9dc9 commit 314bbaa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,9 @@ && collectChildReturnTypes()[0].isDecimalV3()) {
|| fnName.getFunction().equalsIgnoreCase("array_shuffle")
|| fnName.getFunction().equalsIgnoreCase("shuffle")
|| fnName.getFunction().equalsIgnoreCase("array_except")
|| fnName.getFunction().equalsIgnoreCase("array_apply")
|| fnName.getFunction().equalsIgnoreCase("array_position")
|| fnName.getFunction().equalsIgnoreCase("array_contains")
|| fnName.getFunction().equalsIgnoreCase("width_bucket"))
&& (args[ix].isDecimalV3() || (children.get(0).getType().isArrayType()
&& (((ArrayType) children.get(0).getType()).getItemType().isDecimalV3())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
-- !sql --
true

-- !sql --
true

-- !sql --
false

Expand Down Expand Up @@ -86,6 +89,9 @@ true
-- !sql --
true

-- !sql --
2

-- !sql --
1

Expand Down Expand Up @@ -732,7 +738,7 @@ _
[1000002]

-- !sql --
[1.111, 2.222, 3.333]
[2.222, 3.333]

-- !sql --
["2022-01-03 00:00:00", "2021-01-01 00:00:00"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ suite("test_array_functions_by_literal") {


// array_contains function
qt_sql "select array_contains([1.111, 2, 3.333], 2);"
qt_sql "select array_contains([1,2,3], 1)"
qt_sql "select array_contains([1,2,3], 4)"
qt_sql "select array_contains([1,2,3,NULL], 1)"
Expand All @@ -54,6 +55,7 @@ suite("test_array_functions_by_literal") {
qt_sql "select array_contains(array(cast (111.111 as decimalv3(6,3)),cast (222.222 as decimalv3(6,3))), cast (111.111 as decimalv3(6,3)))"

// array_position function
qt_sql "select array_position([1.111, 2, 3.333], 2);"
qt_sql "select array_position([1,2,3], 1)"
qt_sql "select array_position([1,2,3], 3)"
qt_sql "select array_position([1,2,3], 4)"
Expand Down

0 comments on commit 314bbaa

Please sign in to comment.