Skip to content

Commit 8a2af1d

Browse files
committed
chore: add ReferenceSerialization for DataValue::Tuple & fix subquery plan on ReferenceSerialization
1 parent 7bae884 commit 8a2af1d

File tree

17 files changed

+166
-43
lines changed

17 files changed

+166
-43
lines changed

src/binder/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl<'a, 'b, T: Transaction> Binder<'a, 'b, T> {
231231
sub_query: LogicalPlan,
232232
) -> Result<(ScalarExpression, LogicalPlan), DatabaseError> {
233233
let mut alias_column = ColumnCatalog::clone(&column);
234-
alias_column.set_ref_table(self.context.temp_table(), ColumnId::new());
234+
alias_column.set_ref_table(self.context.temp_table(), ColumnId::new(), true);
235235

236236
let alias_expr = ScalarExpression::Alias {
237237
expr: Box::new(ScalarExpression::ColumnRef(column)),

src/binder/select.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,11 @@ impl<'a: 'b, 'b, T: Transaction> Binder<'a, 'b, T> {
353353
for (alias, column) in aliases_with_columns {
354354
let mut alias_column = ColumnCatalog::clone(&column);
355355
alias_column.set_name(alias.clone());
356-
alias_column.set_ref_table(table_alias.clone(), column.id().unwrap_or(ColumnId::new()));
356+
alias_column.set_ref_table(
357+
table_alias.clone(),
358+
column.id().unwrap_or(ColumnId::new()),
359+
true,
360+
);
357361

358362
let alias_column_expr = ScalarExpression::Alias {
359363
expr: Box::new(ScalarExpression::ColumnRef(column)),

src/catalog/column.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub enum ColumnRelation {
4141
Table {
4242
column_id: ColumnId,
4343
table_name: TableName,
44+
is_temp: bool,
4445
},
4546
}
4647

@@ -145,10 +146,11 @@ impl ColumnCatalog {
145146
self.summary.name = name;
146147
}
147148

148-
pub fn set_ref_table(&mut self, table_name: TableName, column_id: ColumnId) {
149+
pub fn set_ref_table(&mut self, table_name: TableName, column_id: ColumnId, is_temp: bool) {
149150
self.summary.relation = ColumnRelation::Table {
150151
column_id,
151152
table_name,
153+
is_temp,
152154
};
153155
}
154156

src/catalog/table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ impl TableCatalog {
100100
col.summary_mut().relation = ColumnRelation::Table {
101101
column_id: col_id,
102102
table_name: self.name.clone(),
103+
is_temp: false,
103104
};
104105

105106
self.column_idxs

src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ pub(crate) mod test {
400400
ColumnDesc::new(LogicalType::Integer, false, false, None).unwrap(),
401401
);
402402
let number_column_id = schema[0].id().unwrap();
403-
column.set_ref_table(Arc::new("a".to_string()), number_column_id);
403+
column.set_ref_table(Arc::new("a".to_string()), number_column_id, true);
404404

405405
debug_assert_eq!(schema, Arc::new(vec![ColumnRef::from(column)]));
406406
debug_assert_eq!(

src/execution/dml/analyze.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ mod test {
159159
use crate::errors::DatabaseError;
160160
use crate::execution::dml::analyze::{DEFAULT_NUM_OF_BUCKETS, DEFAULT_STATISTICS_META_PATH};
161161
use crate::optimizer::core::statistics_meta::StatisticsMeta;
162+
use crate::storage::rocksdb::RocksTransaction;
162163
use std::ffi::OsStr;
163164
use std::fs;
164165
use tempfile::TempDir;
@@ -196,17 +197,17 @@ mod test {
196197
}
197198
paths.sort();
198199

199-
let statistics_meta_pk_index = StatisticsMeta::from_file(&paths[0])?;
200+
let statistics_meta_pk_index = StatisticsMeta::from_file::<RocksTransaction>(&paths[0])?;
200201

201202
assert_eq!(statistics_meta_pk_index.index_id(), 0);
202203
assert_eq!(statistics_meta_pk_index.histogram().values_len(), 101);
203204

204-
let statistics_meta_b_index = StatisticsMeta::from_file(&paths[1])?;
205+
let statistics_meta_b_index = StatisticsMeta::from_file::<RocksTransaction>(&paths[1])?;
205206

206207
assert_eq!(statistics_meta_b_index.index_id(), 1);
207208
assert_eq!(statistics_meta_b_index.histogram().values_len(), 101);
208209

209-
let statistics_meta_p_index = StatisticsMeta::from_file(&paths[2])?;
210+
let statistics_meta_p_index = StatisticsMeta::from_file::<RocksTransaction>(&paths[2])?;
210211

211212
assert_eq!(statistics_meta_p_index.index_id(), 2);
212213
assert_eq!(statistics_meta_p_index.histogram().values_len(), 101);

src/execution/dml/copy_from_file.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ mod tests {
137137
relation: ColumnRelation::Table {
138138
column_id: Ulid::new(),
139139
table_name: Arc::new("t1".to_string()),
140+
is_temp: false,
140141
},
141142
},
142143
false,
@@ -149,6 +150,7 @@ mod tests {
149150
relation: ColumnRelation::Table {
150151
column_id: Ulid::new(),
151152
table_name: Arc::new("t1".to_string()),
153+
is_temp: false,
152154
},
153155
},
154156
false,
@@ -161,6 +163,7 @@ mod tests {
161163
relation: ColumnRelation::Table {
162164
column_id: Ulid::new(),
163165
table_name: Arc::new("t1".to_string()),
166+
is_temp: false,
164167
},
165168
},
166169
false,

src/expression/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,7 @@ mod test {
13821382
relation: ColumnRelation::Table {
13831383
column_id: c3_column_id,
13841384
table_name: Arc::new("t1".to_string()),
1385+
is_temp: false,
13851386
},
13861387
},
13871388
false,

src/optimizer/core/cm_sketch.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::serdes::{ReferenceSerialization, ReferenceTables};
44
use crate::storage::{TableCache, Transaction};
55
use crate::types::value::DataValue;
66
use rand::RngCore;
7-
use serde::{Deserialize, Serialize};
87
use siphasher::sip::SipHasher13;
98
use std::borrow::Borrow;
109
use std::hash::{Hash, Hasher};
@@ -15,7 +14,7 @@ use std::{cmp, mem};
1514
pub(crate) type FastHasher = SipHasher13;
1615

1716
// https://github.com/jedisct1/rust-count-min-sketch
18-
#[derive(Debug, Clone, Serialize, Deserialize)]
17+
#[derive(Debug, Clone)]
1918
pub struct CountMinSketch<K> {
2019
counters: Vec<Vec<usize>>,
2120
offsets: Vec<usize>,

src/optimizer/core/histogram.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::types::index::{IndexId, IndexMeta};
88
use crate::types::value::{DataValue, ValueRef};
99
use crate::types::LogicalType;
1010
use ordered_float::OrderedFloat;
11-
use serde::{Deserialize, Serialize};
1211
use serde_macros::ReferenceSerialization;
1312
use std::collections::Bound;
1413
use std::sync::Arc;
@@ -25,7 +24,7 @@ pub struct HistogramBuilder {
2524
}
2625

2726
// Equal depth histogram
28-
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ReferenceSerialization)]
27+
#[derive(Debug, Clone, PartialEq, ReferenceSerialization)]
2928
pub struct Histogram {
3029
index_id: IndexId,
3130

@@ -40,7 +39,7 @@ pub struct Histogram {
4039
correlation: f64,
4140
}
4241

43-
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ReferenceSerialization)]
42+
#[derive(Debug, Clone, PartialEq, ReferenceSerialization)]
4443
struct Bucket {
4544
lower: ValueRef,
4645
upper: ValueRef,

0 commit comments

Comments
 (0)