From 1427724459891882cd6f1f64b8d90339ea69c6fd Mon Sep 17 00:00:00 2001 From: Jefffrey Date: Wed, 8 Jul 2026 14:29:02 +0900 Subject: [PATCH 1/2] chore: cleanup some TODO items in sqllogictests --- .../test_files/array/array_distinct.slt | 9 +- .../test_files/array/array_empty.slt | 6 +- .../test_files/array/array_has.slt | 12 +- .../test_files/array/array_index.slt | 101 ++++++++----- .../test_files/array/array_pop.slt | 12 +- .../test_files/array/array_position.slt | 6 +- .../test_files/array/array_prepend.slt | 1 - .../test_files/datetime/timestamps.slt | 6 +- datafusion/sqllogictest/test_files/ddl.slt | 4 - datafusion/sqllogictest/test_files/expr.slt | 133 +++++++++--------- datafusion/sqllogictest/test_files/map.slt | 2 +- 11 files changed, 149 insertions(+), 143 deletions(-) diff --git a/datafusion/sqllogictest/test_files/array/array_distinct.slt b/datafusion/sqllogictest/test_files/array/array_distinct.slt index 777ec1ac8a197..2682413cac248 100644 --- a/datafusion/sqllogictest/test_files/array/array_distinct.slt +++ b/datafusion/sqllogictest/test_files/array/array_distinct.slt @@ -19,11 +19,10 @@ include ./init_data.slt.part ## array_distinct -#TODO: https://github.com/apache/datafusion/issues/7142 -#query ? -#select array_distinct(null); -#---- -#NULL +query ? +select array_distinct(null); +---- +NULL # test with empty row, the row that does not match the condition has row count 0 statement ok diff --git a/datafusion/sqllogictest/test_files/array/array_empty.slt b/datafusion/sqllogictest/test_files/array/array_empty.slt index 62ac5f66b74c5..277c69c89e363 100644 --- a/datafusion/sqllogictest/test_files/array/array_empty.slt +++ b/datafusion/sqllogictest/test_files/array/array_empty.slt @@ -69,10 +69,8 @@ false #TODO: https://github.com/apache/datafusion/issues/7142 # empty scalar function #4 -#query B -#select empty(NULL); -#---- -#NULL +query error array_empty does not support type Null +select empty(NULL); # empty scalar function #5 query B diff --git a/datafusion/sqllogictest/test_files/array/array_has.slt b/datafusion/sqllogictest/test_files/array/array_has.slt index e343c1b1fae41..a3e51c39ad436 100644 --- a/datafusion/sqllogictest/test_files/array/array_has.slt +++ b/datafusion/sqllogictest/test_files/array/array_has.slt @@ -41,13 +41,11 @@ select array_has([1, null, 2], 3), false false #TODO: array_has_all and array_has_any cannot handle NULL -#query BBBB -#select array_has_any([], null), -# array_has_any([1, 2, 3], null), -# array_has_all([], null), -# array_has_all([1, 2, 3], null); -#---- -#false false false false +query error array_has does not support type 'Null' +select array_has_any([], null), + array_has_any([1, 2, 3], null), + array_has_all([], null), + array_has_all([1, 2, 3], null); query BBBBBBBBBBBB select array_has(make_array(1,2), 1), diff --git a/datafusion/sqllogictest/test_files/array/array_index.slt b/datafusion/sqllogictest/test_files/array/array_index.slt index 9cd033418d24b..90cdd5f8244a7 100644 --- a/datafusion/sqllogictest/test_files/array/array_index.slt +++ b/datafusion/sqllogictest/test_files/array/array_index.slt @@ -94,17 +94,23 @@ NULL NULL e [13, 14] NULL NULL [NULL, 18] NULL NULL -# TODO: support index as column # single index with columns #5 (index as column) -# query ? -# select make_array(1, 2, 3, 4, 5)[column2] from arrays_with_repeating_elements; -# ---- +query I +select make_array(1, 2, 3, 4, 5)[column2] from arrays_with_repeating_elements; +---- +2 +4 +NULL +NULL -# TODO: support argument and index as columns # single index with columns #6 (argument and index as columns) -# query I -# select column1[column2] from arrays_with_repeating_elements; -# ---- +query I +select column1[column2] from arrays_with_repeating_elements; +---- +2 +5 +7 +10 ## array[i:j] @@ -141,11 +147,11 @@ select arrow_cast([1, 2, 3], 'LargeList(Int64)')[1]; ---- 1 -# TODO: support multiple negative index # multiple index with columns #3 (negative index) -# query II -# select make_array(1, 2, 3)[-3:-1], make_array(1.0, 2.0, 3.0)[-3:-1], make_array('h', 'e', 'l', 'l', 'o')[-2:0]; -# ---- +query ??? +select make_array(1, 2, 3)[-3:-1], make_array(1.0, 2.0, 3.0)[-3:-1], make_array('h', 'e', 'l', 'l', 'o')[-2:0]; +---- +[1, 2, 3] [1.0, 2.0, 3.0] [] # TODO: support complex index # multiple index with columns #4 (complex index) @@ -177,36 +183,56 @@ NULL [13.3, 14.4, 15.5] [a, m, e, t] [[11, 12], [13, 14]] NULL [,] [[15, 16], [NULL, 18]] [16.6, 17.7, 18.8] NULL -# TODO: support negative index # multiple index with columns #3 (negative index) -# query ?RT -# select column1[-2:-4], column2[-3:-5], column3[-1:-4] from arrays; -# ---- -# [NULL, 2] 1.1 m +query ??? +select column1[-2:-4], column2[-3:-5], column3[-1:-4] from arrays; +---- +[] [] [] +[] [] [] +[] [] [] +[] [] [] +NULL [] [] +[] NULL [] +[] [] NULL -# TODO: support complex index # multiple index with columns #4 (complex index) -# query ?RT -# select column1[9 - 7:2 + 2], column2[1 * 0:2 * 3], column3[1 + 1 - 0:5 % 3] from arrays; -# ---- +query ??? +select column1[9 - 7:2 + 2], column2[1 * 0:2 * 3], column3[1 + 1 - 0:5 % 3] from arrays; +---- +[[3, NULL]] [1.1, 2.2, 3.3] [o] +[[5, 6]] [NULL, 5.5, 6.6] [p] +[[7, 8]] [7.7, 8.8, 9.9] [NULL] +[[9, 10]] [10.1, NULL, 12.2] [i] +NULL [13.3, 14.4, 15.5] [m] +[[13, 14]] NULL [] +[[NULL, 18]] [16.6, 17.7, 18.8] NULL -# TODO: support first index as column # multiple index with columns #5 (first index as column) -# query ? -# select make_array(1, 2, 3, 4, 5)[column2:4] from arrays_with_repeating_elements -# ---- +query ? +select make_array(1, 2, 3, 4, 5)[column2:4] from arrays_with_repeating_elements +---- +[2, 3, 4] +[4] +[] +[] -# TODO: support last index as column # multiple index with columns #6 (last index as column) -# query ?RT -# select make_array(1, 2, 3, 4, 5)[2:column3] from arrays_with_repeating_elements; -# ---- +query ? +select make_array(1, 2, 3, 4, 5)[2:column3] from arrays_with_repeating_elements; +---- +[2, 3, 4] +[2, 3, 4, 5] +[2, 3, 4, 5] +[2, 3, 4, 5] -# TODO: support argument and indices as column # multiple index with columns #7 (argument and indices as column) -# query ?RT -# select column1[column2:column3] from arrays_with_repeating_elements; -# ---- +query ? +select column1[column2:column3] from arrays_with_repeating_elements; +---- +[2, 1, 3] +[5, 6, 5, 5] +[7, 8, 7, 7] +[10] # array[i:j:k] @@ -222,12 +248,11 @@ select make_array(1, 2, 3)[0:0:2], make_array(1.0, 2.0, 3.0)[0:2:2], make_array( ---- [] [1.0] [h, l, o] -#TODO: sqlparser does not support negative index ## multiple index with columns #3 (negative index) -#query ??? -#select make_array(1, 2, 3)[-1:-2:-2], make_array(1.0, 2.0, 3.0)[-2:-3:-2], make_array('h', 'e', 'l', 'l', 'o')[-2:-4:-2]; -#---- -#[1] [2.0] [e, l] +query ??? +select make_array(1, 2, 3)[-1:-2:-2], make_array(1.0, 2.0, 3.0)[-2:-3:-2], make_array('h', 'e', 'l', 'l', 'o')[-2:-4:-2]; +---- +[3] [2.0] [l, e] # multiple index with columns #1 (positive index) query ??? diff --git a/datafusion/sqllogictest/test_files/array/array_pop.slt b/datafusion/sqllogictest/test_files/array/array_pop.slt index b830fa464a984..a72e566b9e7ab 100644 --- a/datafusion/sqllogictest/test_files/array/array_pop.slt +++ b/datafusion/sqllogictest/test_files/array/array_pop.slt @@ -22,10 +22,8 @@ include ./init_data.slt.part # array_pop_back scalar function with null #TODO: https://github.com/apache/datafusion/issues/7142 # follow clickhouse and duckdb -#query ? -#select array_pop_back(null); -#---- -#NULL +query error array_pop_back does not support type: Null +select array_pop_back(null); # array_pop_back scalar function #1 query ?? @@ -201,10 +199,8 @@ NULL #TODO:https://github.com/apache/datafusion/issues/7142 # array_pop_front scalar function with null # follow clickhouse and duckdb -#query ? -#select array_pop_front(null); -#---- -#NULL +query error array_pop_front does not support type: Null +select array_pop_front(null); # array_pop_front scalar function #1 query ?? diff --git a/datafusion/sqllogictest/test_files/array/array_position.slt b/datafusion/sqllogictest/test_files/array/array_position.slt index 07e3d3143592c..e3dd830dfb77a 100644 --- a/datafusion/sqllogictest/test_files/array/array_position.slt +++ b/datafusion/sqllogictest/test_files/array/array_position.slt @@ -314,10 +314,8 @@ select array_positions([1, 2, 3, 4, 5], null); #TODO: https://github.com/apache/datafusion/issues/7142 # array_positions with NULL (follow PostgreSQL) -#query ? -#select array_positions(null, 1); -#---- -#NULL +query error array_positions does not support type 'Null' +select array_positions(null, 1); # array_positions scalar function #1 query ??? diff --git a/datafusion/sqllogictest/test_files/array/array_prepend.slt b/datafusion/sqllogictest/test_files/array/array_prepend.slt index 0782680ed2de9..14b53e93b3d0d 100644 --- a/datafusion/sqllogictest/test_files/array/array_prepend.slt +++ b/datafusion/sqllogictest/test_files/array/array_prepend.slt @@ -57,7 +57,6 @@ select array_prepend(null, [[1,2,3]]); # DuckDB: [[]] # ClickHouse: [[]] -# TODO: We may also return [[]] query ? select array_prepend([], []); ---- diff --git a/datafusion/sqllogictest/test_files/datetime/timestamps.slt b/datafusion/sqllogictest/test_files/datetime/timestamps.slt index 06740fa0f5439..8ba095ef934dd 100644 --- a/datafusion/sqllogictest/test_files/datetime/timestamps.slt +++ b/datafusion/sqllogictest/test_files/datetime/timestamps.slt @@ -1936,10 +1936,8 @@ SELECT '2000-01-01T00:00:00'::timestamp - '2010-01-01T00:00:00'::timestamp; -3653 days 0 hours 0 mins 0.000000000 secs # Interval - Timestamp => error -# statement error DataFusion error: Error during planning: Cannot coerce arithmetic expression Interval\(MonthDayNano\) \- Timestamp\(Nanosecond, None\) to valid types -# TODO: This query should raise error -# query P -# SELECT i - ts1 from FOO; +query error Cannot coerce arithmetic expression Interval\(MonthDayNano\) - Timestamp\(ns\) to valid types +SELECT i - ts1 from FOO; statement ok drop table foo; diff --git a/datafusion/sqllogictest/test_files/ddl.slt b/datafusion/sqllogictest/test_files/ddl.slt index 3f2825c09cd54..e1a48ce5e8e3c 100644 --- a/datafusion/sqllogictest/test_files/ddl.slt +++ b/datafusion/sqllogictest/test_files/ddl.slt @@ -200,10 +200,6 @@ SELECT foo_schema.bar.a FROM foo_schema.bar; ---- 1 -# TODO: Drop schema for cleanup, see #6027 -# statement ok -# DROP SCHEMA foo_schema; - ########## # Drop view error tests ########## diff --git a/datafusion/sqllogictest/test_files/expr.slt b/datafusion/sqllogictest/test_files/expr.slt index 51b7591b41199..7e15b48a0d824 100644 --- a/datafusion/sqllogictest/test_files/expr.slt +++ b/datafusion/sqllogictest/test_files/expr.slt @@ -67,7 +67,7 @@ statement error Parser error: Invalid timezone "Foo": failed to parse timezone SELECT arrow_cast('2021-01-02T03:04:00', 'Timestamp(Nanosecond, Some("Foo"))') # test_array_index -query III??IIIIII +query III??IIIIIIII SELECT ([5,4,3,2,1])[1], ([5,4,3,2,1])[2], @@ -80,11 +80,11 @@ SELECT -- out of bounds ([5,4,3,2,1])[0], ([5,4,3,2,1])[6], - -- ([5,4,3,2,1])[-1], -- TODO: wrong answer - -- ([5,4,3,2,1])[null], -- TODO: not supported + ([5,4,3,2,1])[-1], + ([5,4,3,2,1])[null], ([5,4,3,2,1])[100] ---- -5 4 1 [1, 2] [3, 4] 1 3 4 NULL NULL NULL +5 4 1 [1, 2] [3, 4] 1 3 4 NULL NULL 1 NULL NULL # test_array_literals query ????? @@ -330,7 +330,7 @@ SELECT ascii('222') 50 query I -SELECT ascii('0xa') +SELECT ascii('0xa') ---- 48 @@ -561,7 +561,7 @@ NULL query T SELECT ltrim(' zzzytest ') ---- -zzzytest +zzzytest query T SELECT ltrim('zzzytest', 'xyz') @@ -985,17 +985,16 @@ SELECT upper(NULL) ---- NULL -# TODO issue: https://github.com/apache/datafusion/issues/6596 -# query ?? -#SELECT -# CAST([1,2,3,4] AS INT[]) as a, -# CAST([1,2,3,4] AS NUMERIC(10,4)[]) as b -#---- -#[1, 2, 3, 4] [1.0000, 2.0000, 3.0000, 4.0000] +query ?? +SELECT + CAST([1,2,3,4] AS INT[]) as a, + CAST([1,2,3,4] AS NUMERIC(10,4)[]) as b +---- +[1, 2, 3, 4] [1.0000, 2.0000, 3.0000, 4.0000] # test_random_expression query BB -SELECT +SELECT random() BETWEEN 0.0 AND 1.0, random() = random() ---- @@ -1978,15 +1977,15 @@ query B select column1 <=> column2 from (VALUES (1, 1), (2, 3), (NULL, NULL)) as t; ---- true -false +false true # Sanity test - comparing <=> with equivalent expression query B -SELECT - (column1 <=> column2) = +SELECT + (column1 <=> column2) = (IFNULL(column1, false) = IFNULL(column2, false)) AS comparison_result -FROM (VALUES +FROM (VALUES (1, 1), -- equal values (1, 2), -- different values (NULL, NULL), -- both NULL @@ -2280,20 +2279,20 @@ host3 3.3 # can have an aggregate function with an inner CASE WHEN query TR -select - t2.server_host as host, +select + t2.server_host as host, sum(( - case when t2.server_host is not null + case when t2.server_host is not null then t2.server_load2 end - )) + )) from ( - select + select struct(time,load1,load2,host)['c2'] as server_load2, struct(time,load1,load2,host)['c3'] as server_host from t1 - ) t2 - where server_host IS NOT NULL + ) t2 + where server_host IS NOT NULL group by server_host order by host; ---- host1 101 @@ -2302,19 +2301,19 @@ host3 303 # TODO: Issue tracked in https://github.com/apache/datafusion/issues/10364 query TR -select - t2.server['c3'] as host, +select + t2.server['c3'] as host, sum(( - case when t2.server['c3'] is not null + case when t2.server['c3'] is not null then t2.server['c2'] end - )) + )) from ( - select + select struct(time,load1,load2,host) as server from t1 - ) t2 - where t2.server['c3'] IS NOT NULL + ) t2 + where t2.server['c3'] IS NOT NULL group by t2.server['c3'] order by host; ---- host1 101 @@ -2323,22 +2322,22 @@ host3 303 # can have 2 projections with aggr(short_circuited), with different short-circuited expr query TRR -select - t2.server_host as host, +select + t2.server_host as host, sum(coalesce(server_load1)), sum(( - case when t2.server_host is not null + case when t2.server_host is not null then t2.server_load2 end - )) + )) from ( - select + select struct(time,load1,load2,host)['c1'] as server_load1, struct(time,load1,load2,host)['c2'] as server_load2, struct(time,load1,load2,host)['c3'] as server_host from t1 - ) t2 - where server_host IS NOT NULL + ) t2 + where server_host IS NOT NULL group by server_host order by host; ---- host1 1.1 101 @@ -2347,43 +2346,43 @@ host3 3.3 303 # TODO: Issue tracked in https://github.com/apache/datafusion/issues/10364 query error -select - t2.server['c3'] as host, +select + t2.server['c3'] as host, sum(coalesce(server['c1'])), sum(( - case when t2.server['c3'] is not null + case when t2.server['c3'] is not null then t2.server['c2'] end - )) + )) from ( - select + select struct(time,load1,load2,host) as server, from t1 - ) t2 - where server_host IS NOT NULL + ) t2 + where server_host IS NOT NULL group by server_host order by host; query TRR -select - t2.server_host as host, +select + t2.server_host as host, sum(( - case when t2.server_host is not null - then server_load1 + case when t2.server_host is not null + then server_load1 end - )), + )), sum(( - case when server_host is not null - then server_load2 + case when server_host is not null + then server_load2 end - )) + )) from ( - select + select struct(time,load1,load2,host)['c1'] as server_load1, struct(time,load1,load2,host)['c2'] as server_load2, struct(time,load1,load2,host)['c3'] as server_host from t1 - ) t2 - where server_host IS NOT NULL + ) t2 + where server_host IS NOT NULL group by server_host order by host; ---- host1 1.1 101 @@ -2392,24 +2391,24 @@ host3 3.3 303 # TODO: Issue tracked in https://github.com/apache/datafusion/issues/10364 query TRR -select - t2.server['c3'] as host, +select + t2.server['c3'] as host, sum(( - case when t2.server['c3'] is not null + case when t2.server['c3'] is not null then t2.server['c1'] end - )), + )), sum(( - case when t2.server['c3'] is not null + case when t2.server['c3'] is not null then t2.server['c2'] end - )) + )) from ( - select - struct(time,load1,load2,host) as server + select + struct(time,load1,load2,host) as server from t1 - ) t2 - where t2.server['c3'] IS NOT NULL + ) t2 + where t2.server['c3'] IS NOT NULL group by t2.server['c3'] order by host; ---- host1 1.1 101 diff --git a/datafusion/sqllogictest/test_files/map.slt b/datafusion/sqllogictest/test_files/map.slt index 2b390c3748e35..970ae2707d665 100644 --- a/datafusion/sqllogictest/test_files/map.slt +++ b/datafusion/sqllogictest/test_files/map.slt @@ -579,7 +579,7 @@ SELECT MAP { 'a': 1, 'b': 2, 'c': 3 }['a']; # accessing map with non-string key in case expression query I -SELECT (CASE WHEN 1 > 0 THEN MAP {'x': 100} ELSE MAP {'y': 200} END)['x']; +SELECT (CASE WHEN 1 > 0 THEN MAP {'x': 100} ELSE MAP {'y': 200} END)['x']; ---- 100 From da64957b4fab9fc0736fe7247f65463f7940004c Mon Sep 17 00:00:00 2001 From: Jefffrey Date: Thu, 9 Jul 2026 21:55:33 +0900 Subject: [PATCH 2/2] review comments --- datafusion/sqllogictest/test_files/array/array_has.slt | 10 +++++++--- .../sqllogictest/test_files/array/array_index.slt | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/datafusion/sqllogictest/test_files/array/array_has.slt b/datafusion/sqllogictest/test_files/array/array_has.slt index a3e51c39ad436..82712ece89469 100644 --- a/datafusion/sqllogictest/test_files/array/array_has.slt +++ b/datafusion/sqllogictest/test_files/array/array_has.slt @@ -41,10 +41,14 @@ select array_has([1, null, 2], 3), false false #TODO: array_has_all and array_has_any cannot handle NULL -query error array_has does not support type 'Null' +query BB select array_has_any([], null), - array_has_any([1, 2, 3], null), - array_has_all([], null), + array_has_any([1, 2, 3], null); +---- +NULL NULL + +query error array_has does not support type 'Null' +select array_has_all([], null), array_has_all([1, 2, 3], null); query BBBBBBBBBBBB diff --git a/datafusion/sqllogictest/test_files/array/array_index.slt b/datafusion/sqllogictest/test_files/array/array_index.slt index 90cdd5f8244a7..1d9e2989e2342 100644 --- a/datafusion/sqllogictest/test_files/array/array_index.slt +++ b/datafusion/sqllogictest/test_files/array/array_index.slt @@ -153,11 +153,11 @@ select make_array(1, 2, 3)[-3:-1], make_array(1.0, 2.0, 3.0)[-3:-1], make_array( ---- [1, 2, 3] [1.0, 2.0, 3.0] [] -# TODO: support complex index # multiple index with columns #4 (complex index) -# query III -# select make_array(1, 2, 3)[2 + 1 - 1:10], make_array(1.0, 2.0, 3.0)[2 | 2:10], make_array('h', 'e', 'l', 'l', 'o')[6 ^ 6:10]; -# ---- +query ??? +select make_array(1, 2, 3)[2 + 1 - 1:10], make_array(1.0, 2.0, 3.0)[(2 | 2):10], make_array('h', 'e', 'l', 'l', 'o')[6 ^ 6:10]; +---- +[2, 3] [2.0, 3.0] [h, e, l, l, o] # multiple index with columns #1 (positive index) query ???