apache / apache/datafusion

Add additional subquery tests to slt tests

Open
#20,240 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

- Part of https://github.com/apache/datafusion/issues/5483

We are adding support (slowly) for more sophisticated types of subqueries. Part of that is to ensure we have sufficient test coverage.

### Describe the solution you'd like

I would like to make sure we have adequate coverage for subqueries (perhaps by porting) the tests from the duckdb repo to the Datafusion repo

I expect some non trivial number of tests to fail at first

It is important to first evaluate the existing subquery coverage rather than just add many new tests

### Describe alternatives you've considered

Here are some examples of correlated subquery tests from the duckdb repo

- https://github.com/duckdb/duckdb/blob/main/test/sql/subquery/scalar/test_nested_correlated_subquery.test_slow
- https://github.com/duckdb/duckdb/blob/main/test/sql/subquery/scalar/test_complex_nested_correlated_subquery.test
- https://github.com/duckdb/duckdb/blob/main/test/sql/subquery/scalar/nested_subquery_window.test
- https://github.com/duckdb/duckdb/blob/main/test/sql/subquery/table/test_nested_table_subquery.test_slow
- https://github.com/duckdb/duckdb/blob/main/test/sql/subquery/complex/nested_correlated_list.test_slow
- https://github.com/duckdb/duckdb/blob/main/test/sql/subquery/complex/nested_unnest_subquery.test
- https://github.com/duckdb/duckdb/blob/main/test/sql/subquery/scalar/test_scalar_subquery.test
- https://github.com/duckdb/duckdb/blob/main/test/sql/subquery/scalar/test_scalar_subquery_cte.test

I suggest for each of these tests:
1. Porting them over to the datafusion repo (with a link back to their origin)
2. Any tests that now fail to run, add in comments the expected results (from duckdb)

For example, if this query doesn't work

```sql
query II
SELECT i, (SELECT (SELECT (SELECT (SELECT 42+i1.i)++i1.i)+42+i1.i)+42+i1.i) AS j FROM integers i1 ORDER BY i;
----
NULL NULL
1 130
2 134
3 138

```

Let's add something like

```sql
# Expected Results
# reference https://github.com/duckdb/duckdb/blob/324ff8c45f43478e09b6168f75a291b8d43ec3ee/test/sql/subquery/scalar/test_nested_correlated_subquery.test_slow#L29-L32
# ----
# NULL NULL
# 1 130
# 2 134
# 3 138
errror query II
SELECT i, (SELECT (SELECT (SELECT (SELECT 42+i1.i)++i1.i)+42+i1.i)+42+i1.i) AS j FROM integers i1 ORDER BY i;
----
Can't plan query...
```

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by evaluating existing subquery coverage in the SLT tests and compare it with the listed DuckDB subquery test files. Port applicable cases with links to their DuckDB origins, recording expected results for queries that do not run. Done means coverage is expanded and unsupported or failing cases are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases, testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.