[FIX](array)fix if function for array() #22553

[FIX](array)fix if function for array() #22553
This commit is contained in:
amory
2023-08-03 19:40:45 +08:00
committed by GitHub
parent 96a46302e8
commit 469886eb4e
3 changed files with 21 additions and 1 deletions

View File

@ -1707,6 +1707,9 @@ public class FunctionCallExpr extends Expr {
&& args[ix].isDecimalV3OrContainsDecimalV3())) {
// Do not do this cast if types are both decimalv3 with different precision/scale.
uncheckedCastChild(args[ix], i);
} else if (fnName.getFunction().equalsIgnoreCase("if")
&& argTypes[i].isArrayType() && ((ArrayType) argTypes[i]).getItemType().isNull()) {
uncheckedCastChild(args[ix], i);
}
}
}

View File

@ -0,0 +1,13 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select --
\N
-- !select --
["1970-01-01", "1970-01-01"]
-- !select --
["1970-01-01", "1970-01-01"]
-- !select --
[]

View File

@ -16,5 +16,9 @@
// under the License.
suite("test_if") {
sql "select if(id=1,count,hll_empty()) from (select 1 as id, hll_hash(1) as count) t"
qt_select "select if(id=1,count,hll_empty()) from (select 1 as id, hll_hash(1) as count) t"
qt_select "select if(job_d is null, array(), job_d) as test from (select array('1970-01-01', '1970-01-01') as job_d) t"
qt_select "select if(job_d is null, array('1970-01-01'), job_d) as test from (select array('1970-01-01', '1970-01-01') as job_d) t"
qt_select "select if(job_d is null, job_d, array()) as test from (select array('1970-01-01', '1970-01-01') as job_d) t"
}