Skip to content

Commit

Permalink
fix CR
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 committed Dec 27, 2024
1 parent 9817e45 commit cf2ff8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/metric_engine/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl TimeMergeStorage for CloudObjectStorage {
});

let mut plan_for_all_segments = Vec::new();
self.schema.fill_builtin_projections(&mut req.projections);
self.schema.fill_required_projections(&mut req.projections);
for (_, ssts) in ssts_by_segment.sorted_by(|a, b| a.0.cmp(&b.0)) {
let plan = self.parquet_reader.build_df_plan(
ssts,
Expand Down
17 changes: 9 additions & 8 deletions src/metric_engine/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,23 @@ impl StorageSchema {
f.name() == SEQ_COLUMN_NAME || f.name() == RESERVED_COLUMN_NAME
}

pub fn fill_builtin_projections(&self, projection: &mut Option<Vec<usize>>) {
/// Primary keys and builtin columns are required when query.
pub fn fill_required_projections(&self, projection: &mut Option<Vec<usize>>) {
if let Some(proj) = projection.as_mut() {
for i in 0..self.num_primary_keys {
if !proj.contains(&i) {
proj.push(i);
}
}
// For builtin columns, reserved column is not used for now,
// so only add seq column.
if !proj.contains(&self.seq_idx) {
proj.push(self.seq_idx);
}
if !proj.contains(&self.reserved_idx) {
proj.push(self.reserved_idx);
}
}
}

/// Builtin columns are always appended to the end of the schema.
pub fn fill_builtin_columns(
&self,
record_batch: RecordBatch,
Expand Down Expand Up @@ -290,12 +291,12 @@ mod tests {

let mut testcases = [
(None, None),
(Some(vec![]), Some(vec![0, 1, 3, 4])),
(Some(vec![1]), Some(vec![1, 0, 3, 4])),
(Some(vec![4]), Some(vec![4, 0, 1, 3])),
(Some(vec![]), Some(vec![0, 1, 3])),
(Some(vec![1]), Some(vec![1, 0, 3])),
(Some(vec![2]), Some(vec![2, 0, 1, 3])),
];
for (input, expected) in testcases.iter_mut() {
schema.fill_builtin_projections(input);
schema.fill_required_projections(input);
assert_eq!(input, expected);
}
}
Expand Down

0 comments on commit cf2ff8a

Please sign in to comment.