Skip to content

Commit 9e69024

Browse files
authored
[test](cte)add recursive cte test case (#59352)
[test](cte)add recursive cte test case ### What problem does this PR solve? Issue Number: close #xxx Related PR: #xxx Problem Summary: ### Release note None ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
1 parent e40279b commit 9e69024

9 files changed

+2255
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite("column_attribute_null_test") {
19+
20+
String db = context.config.getDbNameByFile(context.file)
21+
def prefix_str = "column_attribute_null_"
22+
def tb_name = prefix_str + "recursive_cte_tb"
23+
def temp_cte_name = prefix_str + "temp_cte_result"
24+
25+
sql """drop table if exists ${tb_name}"""
26+
sql """CREATE TABLE ${tb_name} (
27+
EmployeeID INT not null,
28+
Name VARCHAR(50) not NULL,
29+
ManagerID INT not NULL
30+
) DUPLICATE KEY(EmployeeID)
31+
DISTRIBUTED BY HASH(EmployeeID)
32+
BUCKETS 3 PROPERTIES ('replication_num' = '1');"""
33+
34+
sql """INSERT INTO ${tb_name} VALUES
35+
(100, 'Manager X', 0),
36+
(101, 'Alice', 100),
37+
(102, 'Bob', 100),
38+
(103, 'Charlie', 101),
39+
(104, 'David', 103),
40+
(105, 'Eve', 101);"""
41+
42+
43+
sql """drop view if exists ${temp_cte_name}"""
44+
sql """
45+
CREATE VIEW ${temp_cte_name} AS
46+
WITH recursive SubordinateHierarchy (
47+
EmployeeID,
48+
EmployeeName,
49+
ManagerID,
50+
Level,
51+
Comments
52+
)
53+
AS
54+
(
55+
SELECT
56+
EmployeeID,
57+
Name AS EmployeeName,
58+
ManagerID,
59+
cast(0 as bigint) AS Level,
60+
CAST(NULL AS VARCHAR(100)) AS Comments
61+
FROM
62+
${tb_name}
63+
WHERE
64+
EmployeeID = 100
65+
66+
UNION ALL
67+
68+
SELECT
69+
E.EmployeeID,
70+
E.Name AS EmployeeName,
71+
E.ManagerID,
72+
cast(H.Level + 1 as bigint) AS Level,
73+
cast(H.EmployeeName as VARCHAR(100))
74+
FROM
75+
${tb_name} AS E
76+
INNER JOIN
77+
SubordinateHierarchy AS H
78+
ON E.ManagerID = H.EmployeeID
79+
)
80+
SELECT
81+
*
82+
FROM
83+
SubordinateHierarchy
84+
ORDER BY
85+
Level, EmployeeID;
86+
"""
87+
88+
def desc_res = sql """desc ${temp_cte_name}"""
89+
logger.info("desc_res: " + desc_res)
90+
for (int i = 0; i < desc_res.size(); i++) {
91+
assertTrue(desc_res[i][4] == null)
92+
}
93+
94+
}

0 commit comments

Comments
 (0)