Skip to content

Commit 42f2477

Browse files
authored
fix: ExistsTable should has_result_set. (#15431)
* fix: ExistsTable should has_result_set. * ci: fix exists_tables.test * refactor: let has_result_set = schema.is_empty().
1 parent 0651ef8 commit 42f2477

File tree

2 files changed

+17
-47
lines changed

2 files changed

+17
-47
lines changed

src/query/sql/src/planner/plans/plan.rs

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -479,50 +479,11 @@ impl Plan {
479479
Plan::ExecuteImmediate(plan) => plan.schema(),
480480
Plan::InsertMultiTable(plan) => plan.schema(),
481481

482-
other => {
483-
debug_assert!(!other.has_result_set());
484-
Arc::new(DataSchema::empty())
485-
}
482+
_ => Arc::new(DataSchema::empty()),
486483
}
487484
}
488485

489486
pub fn has_result_set(&self) -> bool {
490-
matches!(
491-
self,
492-
Plan::Query { .. }
493-
| Plan::Explain { .. }
494-
| Plan::ExplainAst { .. }
495-
| Plan::ExplainSyntax { .. }
496-
| Plan::ExplainAnalyze { .. }
497-
| Plan::ShowCreateDatabase(_)
498-
| Plan::ShowCreateTable(_)
499-
| Plan::ShowCreateCatalog(_)
500-
| Plan::ShowFileFormats(_)
501-
| Plan::ShowRoles(_)
502-
| Plan::DescShare(_)
503-
| Plan::ShowShares(_)
504-
| Plan::ShowShareEndpoint(_)
505-
| Plan::ShowObjectGrantPrivileges(_)
506-
| Plan::ShowGrantTenantsOfShare(_)
507-
| Plan::DescribeTable(_)
508-
| Plan::ShowGrants(_)
509-
| Plan::Presign(_)
510-
| Plan::VacuumTable(_)
511-
| Plan::VacuumDropTable(_)
512-
| Plan::VacuumTemporaryFiles(_)
513-
| Plan::DescDatamaskPolicy(_)
514-
| Plan::DescNetworkPolicy(_)
515-
| Plan::ShowNetworkPolicies(_)
516-
| Plan::DescPasswordPolicy(_)
517-
| Plan::CopyIntoTable(_)
518-
| Plan::CopyIntoLocation(_)
519-
| Plan::ShowTasks(_)
520-
| Plan::DescribeTask(_)
521-
| Plan::DescConnection(_)
522-
| Plan::ShowConnections(_)
523-
| Plan::MergeInto(_)
524-
| Plan::ExecuteImmediate(_)
525-
| Plan::InsertMultiTable(_)
526-
)
487+
!self.schema().fields().is_empty()
527488
}
528489
}

tests/sqllogictests/suites/base/05_ddl/05_0023_exists_table.test

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,39 @@ CREATE DATABASE db_05_0023_v2
77
statement ok
88
USE db_05_0023_v2
99

10-
statement ok
10+
query I
1111
EXISTS TABLE t
12+
----
13+
0
1214

13-
statement ok
15+
query I
1416
EXISTS TABLE db_05_0023_v2.t
17+
----
18+
0
1519

1620
statement ok
1721
CREATE TABLE t(c1 int) ENGINE = Fuse
1822

19-
statement ok
23+
query I
2024
EXISTS TABLE t
25+
----
26+
1
2127

22-
statement ok
28+
query I
2329
EXISTS TABLE db_05_0023_v2.t
30+
----
31+
1
2432

2533
statement ok
2634
DROP TABLE t ALL
2735

2836
statement ok
2937
EXISTS TABLE db_05_0023_v2.t
3038

31-
statement ok
39+
query I
3240
EXISTS TABLE t
41+
----
42+
0
3343

3444
statement ok
3545
DROP database db_05_0023_v2
36-

0 commit comments

Comments
 (0)