Skip to content

Refactor: Remove unused re-calculate table statistic logic when creating table with snapshot_location #18842

@dantengsky

Description

@dantengsky

Summary

No longer support creating table with option snapshot_location,

mysql> create table t1(c int) snapshot_location = '1/14579/_ss/h0199962459e6747a8a542d22a1a527ea_v4.mpk';
ERROR 1105 (HY000): TableOptionInvalid. Code: 1301, Text = table option snapshot_location is invalid for create table statement with engine FUSE.
mysql> select version();
+----------------------------------------------------------------------------------------+
| version()                                                                              |
+----------------------------------------------------------------------------------------+
| 8.0.90-v1.2.824-nightly-f259137e89(rust-1.88.0-nightly-2025-10-12T15:10:27.216425000Z) |
+----------------------------------------------------------------------------------------+
1 row in set (0.039 sec)
Read 1 rows, 1.00 B in 0.010 sec., 102.47 rows/sec., 102.47 B/sec.

the following logic is obsoleted:

if let Some(snapshot_loc) = self.plan.options.get(OPT_KEY_SNAPSHOT_LOCATION) {
// using application level data operator is a temp workaround
// please see discussions https://github.com/datafuselabs/databend/pull/10424
let operator = self.ctx.get_application_level_data_operator()?.operator();
let reader = MetaReaders::table_snapshot_reader(operator);
let params = LoadParams {
location: snapshot_loc.clone(),
len_hint: None,
ver: TableSnapshot::VERSION,
put_cache: true,
};
let snapshot = reader.read(&params).await?;
stat = Some(TableStatistics {
number_of_rows: snapshot.summary.row_count,
data_bytes: snapshot.summary.uncompressed_byte_size,
compressed_data_bytes: snapshot.summary.compressed_byte_size,
index_data_bytes: snapshot.summary.index_size,
bloom_index_size: snapshot.summary.bloom_index_size,
ngram_index_size: snapshot.summary.ngram_index_size,
inverted_index_size: snapshot.summary.inverted_index_size,
vector_index_size: snapshot.summary.vector_index_size,
virtual_column_size: snapshot.summary.virtual_column_size,
number_of_segments: Some(snapshot.segments.len() as u64),
number_of_blocks: Some(snapshot.summary.block_count),
});
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions