Skip to content

Commit 68b2885

Browse files
committed
refine mock interface
1 parent 5197090 commit 68b2885

File tree

2 files changed

+14
-37
lines changed

2 files changed

+14
-37
lines changed

optd-cost-model/src/cost/agg.rs

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ mod tests {
6868

6969
use crate::{
7070
common::{
71-
predicates::constant_pred::ConstantType, properties::Attribute, types::TableId,
71+
predicates::constant_pred::ConstantType,
72+
properties::Attribute,
73+
types::{GroupId, TableId},
7274
values::Value,
7375
},
7476
cost_model::tests::{
@@ -82,21 +84,6 @@ mod tests {
8284
#[tokio::test]
8385
async fn test_agg_no_stats() {
8486
let table_id = TableId(0);
85-
// let attr_infos = HashMap::from([(
86-
// table_id,
87-
// vec![
88-
// Attribute {
89-
// name: String::from("attr1"),
90-
// typ: ConstantType::Int32,
91-
// nullable: false,
92-
// },
93-
// Attribute {
94-
// name: String::from("attr2"),
95-
// typ: ConstantType::Int64,
96-
// nullable: false,
97-
// },
98-
// ],
99-
// )]);
10087
let cost_model = create_mock_cost_model(vec![table_id], vec![], vec![None]);
10188

10289
// Group by empty list should return 1.
@@ -124,29 +111,10 @@ mod tests {
124111
#[tokio::test]
125112
async fn test_agg_with_stats() {
126113
let table_id = TableId(0);
114+
let group_id = GroupId(0);
127115
let attr1_base_idx = 0;
128116
let attr2_base_idx = 1;
129117
let attr3_base_idx = 2;
130-
// let attr_infos = HashMap::from([(
131-
// table_id,
132-
// vec![
133-
// Attribute {
134-
// name: String::from("attr1"),
135-
// typ: ConstantType::Int32,
136-
// nullable: false,
137-
// },
138-
// Attribute {
139-
// name: String::from("attr2"),
140-
// typ: ConstantType::Int64,
141-
// nullable: false,
142-
// },
143-
// Attribute {
144-
// name: String::from("attr3"),
145-
// typ: ConstantType::Int64,
146-
// nullable: false,
147-
// },
148-
// ],
149-
// )]);
150118

151119
let attr1_ndistinct = 12;
152120
let attr2_ndistinct = 645;

optd-cost-model/src/cost_model.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ pub mod tests {
173173
table_id: Vec<TableId>,
174174
per_attribute_stats: Vec<HashMap<u64, TestPerAttributeStats>>,
175175
row_counts: Vec<Option<u64>>,
176+
) -> TestOptCostModelMock {
177+
create_mock_cost_model_with_memo(table_id, per_attribute_stats, row_counts, HashMap::new())
178+
}
179+
180+
pub fn create_mock_cost_model_with_memo(
181+
table_id: Vec<TableId>,
182+
per_attribute_stats: Vec<HashMap<u64, TestPerAttributeStats>>,
183+
row_counts: Vec<Option<u64>>,
184+
memo: HashMap<GroupId, MemoGroupInfo>,
176185
) -> TestOptCostModelMock {
177186
let storage_manager = CostModelStorageMockManagerImpl::new(
178187
table_id
@@ -196,7 +205,7 @@ pub mod tests {
196205
CostModelImpl::new(
197206
storage_manager,
198207
CatalogSource::Mock,
199-
Arc::new(MockMemoExtImpl::default()),
208+
Arc::new(MockMemoExtImpl::from(memo)),
200209
)
201210
}
202211

0 commit comments

Comments
 (0)