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

fix: add compatibility for reading non-standard decimal256 format #16585

Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/query/storages/common/table_meta/src/meta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub use statistics::*;
// export legacy versioned table meta types locally,
// currently, used by versioned readers only
pub(crate) use testing::*;
pub use utils::is_possible_non_standard_decimal_block;
pub use utils::parse_storage_prefix;
pub use utils::trim_vacuum2_object_prefix;
pub use utils::try_extract_uuid_str_from_path;
Expand Down
44 changes: 43 additions & 1 deletion src/query/storages/common/table_meta/src/meta/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,27 @@ pub fn parse_storage_prefix(options: &BTreeMap<String, String>, table_id: u64) -

#[inline]
pub fn trim_vacuum2_object_prefix(key: &str) -> &str {
key.strip_prefix(VACUUM2_OBJECT_KEY_PREFIX).unwrap_or(key)
// if object key (the file_name/stem part only) starts with a char which is larger or equals to
// VACUUM2_OBJECT_KEY_PREFIX( i.e. char 'g'), strip it off
if key >= VACUUM2_OBJECT_KEY_PREFIX {
&key[1..]
} else {
key
}
}

pub fn is_possible_non_standard_decimal_block(block_full_path: &str) -> Result<bool> {
let file_name = Path::new(block_full_path)
.file_name()
.ok_or_else(|| {
ErrorCode::StorageOther(format!(
"Illegal block path, no file name found: {}",
block_full_path
))
})?
.to_str()
.expect("File stem of a block full path should always be valid UTF-8");
Ok(file_name < VACUUM2_OBJECT_KEY_PREFIX)
}

// Extracts the UUID part from the object key.
Expand Down Expand Up @@ -144,4 +164,26 @@ mod tests {
assert_eq!(try_extract_uuid_str_from_path(input).unwrap(), expected);
}
}

#[test]
fn test_is_possible_non_standard_decimal_block() {
let test_cases = vec![
(
// stem of block path starts with 'g', should not contain non-standard decimals
"bucket/root/115/122/_b/g0191114d30fd78b89fae8e5c88327725_v2.parquet",
false,
),
(
"bucket/root/115/122/_b/0191114d30fd78b89fae8e5c88327725_v2.parquet",
true,
),
];

for (input, expected) in test_cases {
assert_eq!(
is_possible_non_standard_decimal_block(input).unwrap(),
expected
);
}
}
}
2 changes: 1 addition & 1 deletion src/query/storages/fuse/src/io/locations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl TableMetaLocationGenerator {
pub fn gen_block_location(&self) -> (Location, Uuid) {
let part_uuid = Uuid::new_v4();
let location_path = format!(
"{}/{}/{}{}_v{}.parquet",
"{}/{}/g{}{}_v{}.parquet",
&self.prefix,
FUSE_TBL_BLOCK_PREFIX,
&self.part_prefix,
Expand Down
Loading