Skip to content

Commit 1c7aab2

Browse files
committed
update
1 parent 2638ad7 commit 1c7aab2

File tree

2 files changed

+110
-12
lines changed

2 files changed

+110
-12
lines changed

src/query/functions/tests/it/scalars/array.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ fn test_array_count(file: &mut impl Write) {
424424
run_ast(file, "array_count([1.2, NULL, 3.4, 5.6, NULL])", &[]);
425425
run_ast(file, "array_count(['a', 'b', 'c', 'd', 'e'])", &[]);
426426
run_ast(file, "array_count(['a', 'b', NULL, 'c', 'd', NULL])", &[]);
427+
run_ast(
428+
file,
429+
"array_count(CAST(NULL AS Nullable(Array(Int64))))",
430+
&[],
431+
);
427432

428433
run_ast(file, "array_count([a, b, c, d])", &[
429434
("a", Int16Type::from_data(vec![1i16, 5, 8, 3])),
@@ -469,6 +474,25 @@ fn test_array_count(file: &mut impl Write) {
469474
run_ast(file, "array_count(parse_json('[1, 2, 3, 4, 5]'))", &[]);
470475
run_ast(file, "array_count(parse_json('[1, 2, null, 4, 5]'))", &[]);
471476
run_ast(file, "array_count(parse_json('[1.2, 3.4, 5.6, 7.8]'))", &[]);
477+
478+
{
479+
let mut builder = ColumnBuilder::with_capacity(&DataType::EmptyArray, 3);
480+
for _ in 0..3 {
481+
builder.push_default();
482+
}
483+
let column = builder.build();
484+
run_ast(file, "array_count(a)", &[("a", column)]);
485+
}
486+
487+
{
488+
let data_type = DataType::EmptyArray.wrap_nullable();
489+
let mut builder = ColumnBuilder::with_capacity(&data_type, 3);
490+
builder.push_default();
491+
builder.push(Scalar::EmptyArray.as_ref());
492+
builder.push_default();
493+
let column = builder.build();
494+
run_ast(file, "array_count(a)", &[("a", column)]);
495+
}
472496
}
473497

474498
fn test_array_max(file: &mut impl Write) {
@@ -479,6 +503,11 @@ fn test_array_max(file: &mut impl Write) {
479503
run_ast(file, "array_max([1.2, NULL, 3.4, 5.6, NULL])", &[]);
480504
run_ast(file, "array_max(['a', 'b', 'c', 'd', 'e'])", &[]);
481505
run_ast(file, "array_max(['a', 'b', NULL, 'c', 'd', NULL])", &[]);
506+
run_ast(
507+
file,
508+
"array_max(CAST(NULL AS Nullable(Array(Int64))))",
509+
&[],
510+
);
482511

483512
{
484513
let data_type = DataType::Array(Box::new(Int16Type::data_type())).wrap_nullable();
@@ -528,6 +557,25 @@ fn test_array_max(file: &mut impl Write) {
528557
"array_max(parse_json('[\"a\", \"b\", \"c\", \"d\"]'))",
529558
&[],
530559
);
560+
561+
{
562+
let mut builder = ColumnBuilder::with_capacity(&DataType::EmptyArray, 2);
563+
for _ in 0..2 {
564+
builder.push_default();
565+
}
566+
let column = builder.build();
567+
run_ast(file, "array_max(a)", &[("a", column)]);
568+
}
569+
570+
{
571+
let data_type = DataType::EmptyArray.wrap_nullable();
572+
let mut builder = ColumnBuilder::with_capacity(&data_type, 3);
573+
builder.push_default();
574+
builder.push(Scalar::EmptyArray.as_ref());
575+
builder.push_default();
576+
let column = builder.build();
577+
run_ast(file, "array_max(a)", &[("a", column)]);
578+
}
531579
}
532580

533581
fn test_array_min(file: &mut impl Write) {

src/query/functions/tests/it/scalars/testdata/array.txt

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,15 @@ output domain : {4..=4}
14911491
output : 4
14921492

14931493

1494+
ast : array_count(CAST(NULL AS Nullable(Array(Int64))))
1495+
raw expr : array_count(CAST(NULL AS Array(Int64) NULL))
1496+
checked expr : array_count<Array(Int64) NULL>(CAST<NULL>(NULL AS Array(Int64) NULL))
1497+
optimized expr : NULL
1498+
output type : UInt64 NULL
1499+
output domain : {NULL}
1500+
output : NULL
1501+
1502+
14941503
ast : array_count([a, b, c, d])
14951504
raw expr : array_count(array(a::Int16, b::Int16, c::Int16, d::Int16))
14961505
checked expr : array_count<Array(Int16)>(array<T0=Int16><T0, T0, T0, T0>(a, b, c, d))
@@ -1532,12 +1541,12 @@ evaluation:
15321541
| Row 3 | NULL | NULL |
15331542
+--------+--------------------+-------------+
15341543
evaluation (internal):
1535-
+--------+--------------------------------------------------------------------------------------------------------------------------------+
1536-
| Column | Data |
1537-
+--------+--------------------------------------------------------------------------------------------------------------------------------+
1538-
| a | NullableColumn { column: ArrayColumn { values: Int16([1, 5, 8, 3, 1, 5]), offsets: [0, 0, 4, 6, 6] }, validity: [0b____0110] } |
1539-
| Output | NullableColumn { column: UInt64([0, 4, 2, 0]), validity: [0b____0110] } |
1540-
+--------+--------------------------------------------------------------------------------------------------------------------------------+
1544+
+--------+----------------------------------------------------------------------------------------------------------------------------------------+
1545+
| Column | Data |
1546+
+--------+----------------------------------------------------------------------------------------------------------------------------------------+
1547+
| a | Column(NullableColumn { column: ArrayColumn { values: Int16([1, 5, 8, 3, 1, 5]), offsets: [0, 0, 4, 6, 6] }, validity: [0b____0110] }) |
1548+
| Output | NullableColumn { column: UInt64([0, 4, 2, 0]), validity: [0b____0110] } |
1549+
+--------+----------------------------------------------------------------------------------------------------------------------------------------+
15411550

15421551

15431552
ast : array_count([a, b, c, d])
@@ -1593,6 +1602,22 @@ output domain : {4..=4}
15931602
output : 4
15941603

15951604

1605+
ast : array_count(a)
1606+
raw expr : array_count(a::Array(Nothing))
1607+
checked expr : array_count<Array(Nothing)>(a)
1608+
output type : UInt64
1609+
output domain : Unknown
1610+
output : 0
1611+
1612+
1613+
ast : array_count(a)
1614+
raw expr : array_count(a::Array(Nothing) NULL)
1615+
checked expr : array_count<Array(Nothing) NULL>(a)
1616+
output type : UInt64 NULL
1617+
output domain : Unknown
1618+
output : NULL
1619+
1620+
15961621
ast : array_max([])
15971622
raw expr : array_max(array())
15981623
checked expr : array_max<Array(Nothing)>(array<>())
@@ -1656,6 +1681,15 @@ output domain : {"d"..="d"}
16561681
output : 'd'
16571682

16581683

1684+
ast : array_max(CAST(NULL AS Nullable(Array(Int64))))
1685+
raw expr : array_max(CAST(NULL AS Array(Int64) NULL))
1686+
checked expr : array_max<Array(Int64) NULL>(CAST<NULL>(NULL AS Array(Int64) NULL))
1687+
optimized expr : NULL
1688+
output type : Int64 NULL
1689+
output domain : {NULL}
1690+
output : NULL
1691+
1692+
16591693
ast : array_max(a)
16601694
raw expr : array_max(a::Array(Int16) NULL)
16611695
checked expr : array_max<Array(Int16) NULL>(a)
@@ -1671,12 +1705,12 @@ evaluation:
16711705
| Row 3 | NULL | NULL |
16721706
+--------+--------------------+------------+
16731707
evaluation (internal):
1674-
+--------+--------------------------------------------------------------------------------------------------------------------------------+
1675-
| Column | Data |
1676-
+--------+--------------------------------------------------------------------------------------------------------------------------------+
1677-
| a | NullableColumn { column: ArrayColumn { values: Int16([1, 5, 8, 3, 1, 5]), offsets: [0, 0, 4, 6, 6] }, validity: [0b____0110] } |
1678-
| Output | NullableColumn { column: Int16([0, 8, 5, 0]), validity: [0b____0110] } |
1679-
+--------+--------------------------------------------------------------------------------------------------------------------------------+
1708+
+--------+----------------------------------------------------------------------------------------------------------------------------------------+
1709+
| Column | Data |
1710+
+--------+----------------------------------------------------------------------------------------------------------------------------------------+
1711+
| a | Column(NullableColumn { column: ArrayColumn { values: Int16([1, 5, 8, 3, 1, 5]), offsets: [0, 0, 4, 6, 6] }, validity: [0b____0110] }) |
1712+
| Output | NullableColumn { column: Int16([0, 8, 5, 0]), validity: [0b____0110] } |
1713+
+--------+----------------------------------------------------------------------------------------------------------------------------------------+
16801714

16811715

16821716
ast : array_max([a, b, c, d])
@@ -1758,6 +1792,22 @@ output domain : Undefined
17581792
output : '"d"'
17591793

17601794

1795+
ast : array_max(a)
1796+
raw expr : array_max(a::Array(Nothing))
1797+
checked expr : array_max<Array(Nothing)>(a)
1798+
output type : NULL
1799+
output domain : Unknown
1800+
output : NULL
1801+
1802+
1803+
ast : array_max(a)
1804+
raw expr : array_max(a::Array(Nothing) NULL)
1805+
checked expr : array_max<Array(Nothing) NULL>(a)
1806+
output type : NULL
1807+
output domain : Unknown
1808+
output : NULL
1809+
1810+
17611811
ast : array_min([])
17621812
raw expr : array_min(array())
17631813
checked expr : array_min<Array(Nothing)>(array<>())

0 commit comments

Comments
 (0)