Skip to content

Consolidate cte_quoted_reference.slt into cte.slt#19862

Merged
alamb merged 1 commit intoapache:mainfrom
AnjaliChoudhary99:consolidate-cte-tests
Jan 20, 2026
Merged

Consolidate cte_quoted_reference.slt into cte.slt#19862
alamb merged 1 commit intoapache:mainfrom
AnjaliChoudhary99:consolidate-cte-tests

Conversation

@AnjaliChoudhary99
Copy link
Copy Markdown
Contributor

  • Merged CTE reference resolution tests into main cte.slt file
  • Added CREATE TABLE statement for orders table used in tests
  • Fixed 3 case-sensitivity issues: changed 'WHERE N < 10' to 'WHERE n < 10'

Fixes #19786

Which issue does this PR close?

Rationale for this change

This PR consolidates the small test file cte_quoted_reference.slt into the main cte.slt file as requested in issue #19786. The separate file was small enough that it didn't need to be maintained independently, and consolidating it improves code organization and maintainability.

What changes are included in this PR?

  • Merged CTE reference resolution tests from cte_quoted_reference.slt into cte.slt
  • Added CREATE TABLE orders AS VALUES (1), (2); statement to support the merged tests
  • Fixed 3 pre-existing case-sensitivity bugs by changing WHERE N < 10 to WHERE n < 10 in recursive CTE tests
  • Deleted cte_quoted_reference.slt as it's now consolidated into the main file

Are these changes tested?

Yes, all changes are tested:

  • The consolidated tests from cte_quoted_reference.slt are now part of the cte.slt test suite
  • All sqllogictest tests pass successfully: cargo test --test sqllogictests -- cte
  • The case-sensitivity fixes ensure that field references match their definitions (lowercase n)

Are there any user-facing changes?

No, there are no user-facing changes. This is purely a test file reorganization that improves code maintainability without affecting DataFusion's functionality or API.

- Merged CTE reference resolution tests into main cte.slt file
- Added CREATE TABLE statement for orders table used in tests
- Fixed 3 case-sensitivity issues: changed 'WHERE N < 10' to 'WHERE n < 10'

Fixes apache#19786
Copy link
Copy Markdown
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed 3 pre-existing case-sensitivity bugs by changing WHERE N < 10 to WHERE n < 10 in recursive CTE tests

Not exactly sure how these are bugs 🤔

----
1
2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to ensure we cleanup the orders table to ensure this section of tests are isolated

@alamb
Copy link
Copy Markdown
Contributor

alamb commented Jan 18, 2026

Thank you @AnjaliChoudhary99

@alamb alamb added this pull request to the merge queue Jan 20, 2026
Merged via the queue into apache:main with commit 5b122cc Jan 20, 2026
28 checks passed
github-merge-queue Bot pushed a commit that referenced this pull request Mar 22, 2026
## Which issue does this PR close?

N/A

## Rationale for this change

PR #19519 introduces new tests
to verify that DataFusion won't unexpectedly lookup CTE names from the
catalog. It registers a strict SchemaProvider that panics with
unexpected table lookups.

https://github.com/apache/datafusion/blob/d138c36cb08c2dc028b29bbd20853b24cf0f3b8b/datafusion/sqllogictest/src/test_context.rs#L230-L241

The problem is that PR #19862 skips registering the strict
SchemaProvider and bypasses the unexpected lookup check. Therefore,
there tests become meaningless.


<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->

## What changes are included in this PR?

Re-register the strict SchemaProvider into cte.slt.

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

## Are these changes tested?
Yes. 

I also backported these new tests to tag 52.0.0, which does not include
the fix in #19519, and they
failed as expected.
```sh
$ cargo test --profile release-nonlto --test sqllogictests -- cte
   Compiling datafusion-sqllogictest v52.0.0 (/Users/jonah/Work/datafusion/datafusion/sqllogictest)
    Finished `release-nonlto` profile [optimized] target(s) in 19.50s
     Running bin/sqllogictests.rs (/Users/jonah/Work/datafusion/target/release-nonlto/deps/sqllogictests-f9c15c7896eb5af9)
[00:00:00] ####------------------------------------       6/75      "cte.slt"
thread 'tokio-runtime-worker' (486408) panicked at datafusion/sqllogictest/src/test_context.rs:215:22:
unexpected table lookup: barbaz. This maybe indicates a CTE reference was incorrectly treated as a catalog table reference.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Completed 3 test files in 0 seconds                                                                                                                                                          failure in cte.slt for sql with barbaz as (select * from orders) select * from "barbaz";
caused by
External error: task 13 panicked with message "unexpected table lookup: barbaz. This maybe indicates a CTE reference was incorrectly treated as a catalog table reference."
Error: Execution("1 failures")
error: test failed, to rerun pass `-p datafusion-sqllogictest --test sqllogictests`
```

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

## Are there any user-facing changes?
No.
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->

<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->

---------

Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
de-bgunter pushed a commit to de-bgunter/datafusion that referenced this pull request Mar 24, 2026
- Merged CTE reference resolution tests into main cte.slt file
- Added CREATE TABLE statement for orders table used in tests
- Fixed 3 case-sensitivity issues: changed 'WHERE N < 10' to 'WHERE n <
10'

Fixes apache#19786

## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes apache#123` indicates that this PR will close issue apache#123.
-->
- Closes apache#19786

## Rationale for this change

<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
This PR consolidates the small test file `cte_quoted_reference.slt` into
the main `cte.slt` file as requested in issue apache#19786. The separate file
was small enough that it didn't need to be maintained independently, and
consolidating it improves code organization and maintainability.

## What changes are included in this PR?

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
- Merged CTE reference resolution tests from `cte_quoted_reference.slt`
into `cte.slt`
- Added `CREATE TABLE orders AS VALUES (1), (2);` statement to support
the merged tests
- Fixed 3 pre-existing case-sensitivity bugs by changing `WHERE N < 10`
to `WHERE n < 10` in recursive CTE tests
- Deleted `cte_quoted_reference.slt` as it's now consolidated into the
main file

## Are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

Yes, all changes are tested:
- The consolidated tests from `cte_quoted_reference.slt` are now part of
the `cte.slt` test suite
- All sqllogictest tests pass successfully: `cargo test --test
sqllogictests -- cte`
- The case-sensitivity fixes ensure that field references match their
definitions (lowercase `n`)


## Are there any user-facing changes?

<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
No, there are no user-facing changes. This is purely a test file
reorganization that improves code maintainability without affecting
DataFusion's functionality or API.


<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->

Co-authored-by: Anjali Choudhary <anjalicy@amazon.com>
de-bgunter pushed a commit to de-bgunter/datafusion that referenced this pull request Mar 24, 2026
## Which issue does this PR close?

N/A

## Rationale for this change

PR apache#19519 introduces new tests
to verify that DataFusion won't unexpectedly lookup CTE names from the
catalog. It registers a strict SchemaProvider that panics with
unexpected table lookups.

https://github.com/apache/datafusion/blob/d138c36cb08c2dc028b29bbd20853b24cf0f3b8b/datafusion/sqllogictest/src/test_context.rs#L230-L241

The problem is that PR apache#19862 skips registering the strict
SchemaProvider and bypasses the unexpected lookup check. Therefore,
there tests become meaningless.


<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->

## What changes are included in this PR?

Re-register the strict SchemaProvider into cte.slt.

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

## Are these changes tested?
Yes. 

I also backported these new tests to tag 52.0.0, which does not include
the fix in apache#19519, and they
failed as expected.
```sh
$ cargo test --profile release-nonlto --test sqllogictests -- cte
   Compiling datafusion-sqllogictest v52.0.0 (/Users/jonah/Work/datafusion/datafusion/sqllogictest)
    Finished `release-nonlto` profile [optimized] target(s) in 19.50s
     Running bin/sqllogictests.rs (/Users/jonah/Work/datafusion/target/release-nonlto/deps/sqllogictests-f9c15c7896eb5af9)
[00:00:00] ####------------------------------------       6/75      "cte.slt"
thread 'tokio-runtime-worker' (486408) panicked at datafusion/sqllogictest/src/test_context.rs:215:22:
unexpected table lookup: barbaz. This maybe indicates a CTE reference was incorrectly treated as a catalog table reference.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Completed 3 test files in 0 seconds                                                                                                                                                          failure in cte.slt for sql with barbaz as (select * from orders) select * from "barbaz";
caused by
External error: task 13 panicked with message "unexpected table lookup: barbaz. This maybe indicates a CTE reference was incorrectly treated as a catalog table reference."
Error: Execution("1 failures")
error: test failed, to rerun pass `-p datafusion-sqllogictest --test sqllogictests`
```

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

## Are there any user-facing changes?
No.
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->

<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->

---------

Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate datafusion/sqllogictest/test_files/cte_quoted_reference.slt

4 participants