Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(query): fix lazy columns missed in constant table scan #17258

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/query/sql/src/planner/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ impl Metadata {
self.lazy_columns.extend(indices);
}

pub fn clear_lazy_columns(&mut self) {
self.lazy_columns.clear();
}

pub fn add_non_lazy_columns(&mut self, indices: HashSet<usize>) {
debug_assert!(indices.iter().all(|i| *i < self.columns.len()));
self.non_lazy_columns.extend(indices);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ impl Rule for RuleEliminateFilter {
.derive_relational_prop(&RelExpr::with_s_expr(s_expr))?
.output_columns
.clone();

{
let mut metadata = self.metadata.write();
metadata.clear_lazy_columns();
}

let metadata = self.metadata.read();
let mut fields = Vec::with_capacity(output_columns.len());

Expand Down
8 changes: 8 additions & 0 deletions tests/sqllogictests/suites/query/issues/issue_17158.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
statement ok
create table tt2 (c0 bool, c1 int);

statement ok
insert into tt2 values(true, 1),(false, 2),(true, 3);

statement ok
select null, c0, 30, c1 from tt2 where false order by c0 LIMIT 3 OFFSET 0;
Loading