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

refactor: mark all partition as lazy and handle them using a pipeline #17229

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
54 changes: 14 additions & 40 deletions src/query/storages/fuse/src/operations/read_partitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ use sha2::Sha256;

use crate::fuse_part::FuseBlockPartInfo;
use crate::io::BloomIndexBuilder;
use crate::pruning::create_segment_location_vector;
use crate::pruning::table_sample;
use crate::pruning::BlockPruner;
use crate::pruning::FusePruner;
Expand All @@ -81,9 +80,8 @@ impl FuseTable {
&self,
ctx: Arc<dyn TableContext>,
push_downs: Option<PushDownInfo>,
dry_run: bool,
_dry_run: bool,
) -> Result<(PartStatistics, Partitions)> {
let distributed_pruning = ctx.get_settings().get_enable_distributed_pruning()?;
if let Some(changes_desc) = &self.changes_desc {
// For "ANALYZE TABLE" statement, we need set the default change type to "Insert".
let change_type = push_downs.as_ref().map_or(ChangeType::Insert, |v| {
Expand All @@ -108,45 +106,21 @@ impl FuseTable {
.meta_location_generator
.snapshot_location_from_uuid(&snapshot.snapshot_id, snapshot.format_version)?;

let mut nodes_num = 1;
let cluster = ctx.get_cluster();

if !cluster.is_empty() {
nodes_num = cluster.nodes.len();
}

if !dry_run && snapshot.segments.len() > nodes_num && distributed_pruning {
let mut segments = Vec::with_capacity(snapshot.segments.len());
for (idx, segment_location) in snapshot.segments.iter().enumerate() {
segments.push(FuseLazyPartInfo::create(idx, segment_location.clone()))
}

return Ok((
PartStatistics::new_estimated(
Some(snapshot_loc),
snapshot.summary.row_count as usize,
snapshot.summary.compressed_byte_size as usize,
snapshot.segments.len(),
snapshot.segments.len(),
),
Partitions::create(PartitionsShuffleKind::Mod, segments),
));
let mut segments = Vec::with_capacity(snapshot.segments.len());
for (idx, segment_location) in snapshot.segments.iter().enumerate() {
segments.push(FuseLazyPartInfo::create(idx, segment_location.clone()))
}

let snapshot_loc = Some(snapshot_loc);
let table_schema = self.schema_with_stream();
let summary = snapshot.summary.block_count as usize;
let segments_location =
create_segment_location_vector(snapshot.segments.clone(), snapshot_loc);

self.prune_snapshot_blocks(
ctx.clone(),
push_downs.clone(),
table_schema,
segments_location,
summary,
)
.await
Ok((
PartStatistics::new_estimated(
Some(snapshot_loc),
snapshot.summary.row_count as usize,
snapshot.summary.compressed_byte_size as usize,
snapshot.segments.len(),
snapshot.segments.len(),
),
Partitions::create(PartitionsShuffleKind::Mod, segments),
))
}
None => Ok((PartStatistics::default(), Partitions::default())),
}
Expand Down
Loading