This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 5b122cc0dd Consolidate cte_quoted_reference.slt into cte.slt (#19862)
5b122cc0dd is described below

commit 5b122cc0dd73034205099cb4237518982770fb16
Author: Anjali Choudhary <[email protected]>
AuthorDate: Tue Jan 20 19:00:00 2026 +0530

    Consolidate cte_quoted_reference.slt into cte.slt (#19862)
    
    - 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?
    
    <!--
    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 #123` indicates that this PR will close issue #123.
    -->
    - Closes #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 #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 <[email protected]>
---
 datafusion/sqllogictest/test_files/cte.slt         | 63 ++++++++++++++++++-
 .../test_files/cte_quoted_reference.slt            | 70 ----------------------
 2 files changed, 60 insertions(+), 73 deletions(-)

diff --git a/datafusion/sqllogictest/test_files/cte.slt 
b/datafusion/sqllogictest/test_files/cte.slt
index 3dac929387..4fd77be045 100644
--- a/datafusion/sqllogictest/test_files/cte.slt
+++ b/datafusion/sqllogictest/test_files/cte.slt
@@ -42,6 +42,63 @@ physical_plan
 statement error DataFusion error: Error during planning: WITH query name "a" 
specified more than once
 WITH a AS (SELECT 1), a AS (SELECT 2) SELECT * FROM a;
 
+statement ok
+CREATE TABLE orders AS VALUES (1), (2);
+
+##########
+## CTE Reference Resolution
+##########
+
+# These tests exercise CTE reference resolution with and without identifier
+# normalization. The session is configured with a strict catalog/schema 
provider
+# (see `datafusion/sqllogictest/src/test_context.rs`) that only provides the
+# `orders` table and panics on any unexpected table lookup.
+#
+# This makes it observable if DataFusion incorrectly treats a CTE reference as 
a
+# catalog lookup.
+#
+# Refs: https://github.com/apache/datafusion/issues/18932
+#
+# NOTE: This test relies on a strict catalog/schema provider registered in
+# `datafusion/sqllogictest/src/test_context.rs` that provides only the `orders`
+# table and panics on unexpected lookups.
+
+statement ok
+set datafusion.sql_parser.enable_ident_normalization = true;
+
+query I
+with barbaz as (select * from orders) select * from "barbaz";
+----
+1
+2
+
+query I
+with BarBaz as (select * from orders) select * from "barbaz";
+----
+1
+2
+
+query I
+with barbaz as (select * from orders) select * from barbaz;
+----
+1
+2
+
+statement ok
+set datafusion.sql_parser.enable_ident_normalization = false;
+
+query I
+with barbaz as (select * from orders) select * from "barbaz";
+----
+1
+2
+
+query I
+with barbaz as (select * from orders) select * from barbaz;
+----
+1
+2
+
 # Test disabling recursive CTE
 statement ok
 set datafusion.execution.enable_recursive_ctes = false;
@@ -996,7 +1053,7 @@ query TT
 explain WITH RECURSIVE numbers AS (
   select 1 as n
   UNION ALL
-  select n + 1 FROM numbers WHERE N < 10
+  select n + 1 FROM numbers WHERE n < 10
 ) select * from numbers;
 ----
 logical_plan
@@ -1021,7 +1078,7 @@ query TT
 explain WITH RECURSIVE numbers AS (
   select 1 as n
   UNION ALL
-  select n + 1 FROM numbers WHERE N < 10
+  select n + 1 FROM numbers WHERE n < 10
 ) select * from numbers;
 ----
 logical_plan
@@ -1160,5 +1217,5 @@ query error DataFusion error: This feature is not 
implemented: Recursive CTEs ar
 explain WITH RECURSIVE numbers AS (
   select 1 as n
   UNION ALL
-  select n + 1 FROM numbers WHERE N < 10
+  select n + 1 FROM numbers WHERE n < 10
 ) select * from numbers;
diff --git a/datafusion/sqllogictest/test_files/cte_quoted_reference.slt 
b/datafusion/sqllogictest/test_files/cte_quoted_reference.slt
deleted file mode 100644
index 6142157e5e..0000000000
--- a/datafusion/sqllogictest/test_files/cte_quoted_reference.slt
+++ /dev/null
@@ -1,70 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-##########
-## CTE Reference Resolution
-##########
-
-# These tests exercise CTE reference resolution with and without identifier
-# normalization. The session is configured with a strict catalog/schema 
provider
-# (see `datafusion/sqllogictest/src/test_context.rs`) that only provides the
-# `orders` table and panics on any unexpected table lookup.
-#
-# This makes it observable if DataFusion incorrectly treats a CTE reference as 
a
-# catalog lookup.
-#
-# Refs: https://github.com/apache/datafusion/issues/18932
-#
-# NOTE: This test relies on a strict catalog/schema provider registered in
-# `datafusion/sqllogictest/src/test_context.rs` that provides only the `orders`
-# table and panics on unexpected lookups.
-
-statement ok
-set datafusion.sql_parser.enable_ident_normalization = true;
-
-query I
-with barbaz as (select * from orders) select * from "barbaz";
-----
-1
-2
-
-query I
-with BarBaz as (select * from orders) select * from "barbaz";
-----
-1
-2
-
-query I
-with barbaz as (select * from orders) select * from barbaz;
-----
-1
-2
-
-statement ok
-set datafusion.sql_parser.enable_ident_normalization = false;
-
-query I
-with barbaz as (select * from orders) select * from "barbaz";
-----
-1
-2
-
-query I
-with barbaz as (select * from orders) select * from barbaz;
-----
-1
-2


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to