Skip to content

Commit

Permalink
fix: lazy materialization does not support set operation (#15754)
Browse files Browse the repository at this point in the history
* fix: lazy materialization does not support set operation

* add tests
  • Loading branch information
xudong963 committed Jun 11, 2024
1 parent af80f64 commit 17c3411
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/query/sql/src/executor/physical_plans/physical_table_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,14 @@ impl PhysicalPlanBuilder {
let internal_column = INTERNAL_COLUMN_FACTORY
.get_internal_column(ROW_ID_COL_NAME)
.unwrap();
let index = self
if let Some(index) = self
.metadata
.read()
.row_id_index_by_table_index(scan.table_index);
debug_assert!(index.is_some());
// Safe to unwrap: if lazy_columns is not empty, the `analyze_lazy_materialization` have been called
// and the row_id index of the table_index has been generated.
let index = index.unwrap();
entry.insert(index);
project_internal_columns.insert(index, internal_column);
.row_id_index_by_table_index(scan.table_index)
{
entry.insert(index);
project_internal_columns.insert(index, internal_column);
}
}
}

Expand Down
14 changes: 14 additions & 0 deletions tests/sqllogictests/suites/query/union.test
Original file line number Diff line number Diff line change
Expand Up @@ -276,5 +276,19 @@ SELECT
----
10086

statement ok
create or replace table t (n bigint);

statement ok
insert into t (n) values (1);

query I
with t1 as (SELECT user_id AS root_uid FROM test4 where parent is not null limit 2), t2 as (SELECT 10086 AS root_uid from t limit 200) select * from t1 union all select * from t2;
----
10086

statement ok
drop table test4;

statement ok
drop table t;

0 comments on commit 17c3411

Please sign in to comment.