Skip to content

Commit 5671a5c

Browse files
authored
fix(cubestore): Natural order for Int96 and Decimal96 (#7419)
1 parent 4bb9cea commit 5671a5c

File tree

2 files changed

+115
-4
lines changed

2 files changed

+115
-4
lines changed

rust/cubestore/Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubestore/cubestore/src/store/compaction.rs

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,117 @@ mod tests {
19661966
let _ = fs::remove_dir_all(chunk_remote_store_path.clone());
19671967
}
19681968

1969+
#[tokio::test]
1970+
async fn partition_compaction_int96() {
1971+
Config::test("partition_compaction_int96")
1972+
.update_config(|mut c| {
1973+
c.partition_split_threshold = 20;
1974+
c
1975+
})
1976+
.start_test(async move |services| {
1977+
let service = services.sql_service;
1978+
let _ = service.exec_query("CREATE SCHEMA test").await.unwrap();
1979+
let compaction_service = services
1980+
.injector
1981+
.get_service_typed::<dyn CompactionService>()
1982+
.await;
1983+
service
1984+
.exec_query("create table test.a (a int, b int96)")
1985+
.await
1986+
.unwrap();
1987+
let values = (0..15)
1988+
.map(|i| format!("({}, {})", i, i))
1989+
.collect::<Vec<_>>()
1990+
.join(", ");
1991+
let query = format!("insert into test.a (a, b) values {}", values);
1992+
service.exec_query(&query).await.unwrap();
1993+
compaction_service
1994+
.compact(1, DataLoadedSize::new())
1995+
.await
1996+
.unwrap();
1997+
let partitions = services
1998+
.meta_store
1999+
.get_active_partitions_by_index_id(1)
2000+
.await
2001+
.unwrap();
2002+
assert_eq!(partitions.len(), 1);
2003+
let values = (0..30)
2004+
.map(|i| format!("({}, {})", i, i))
2005+
.collect::<Vec<_>>()
2006+
.join(", ");
2007+
2008+
let query = format!("insert into test.a (a, b) values {}", values);
2009+
2010+
service.exec_query(&query).await.unwrap();
2011+
compaction_service
2012+
.compact(partitions[0].get_id(), DataLoadedSize::new())
2013+
.await
2014+
.unwrap();
2015+
let partitions = services
2016+
.meta_store
2017+
.get_active_partitions_by_index_id(1)
2018+
.await
2019+
.unwrap();
2020+
assert_eq!(partitions.len(), 3);
2021+
})
2022+
.await;
2023+
}
2024+
2025+
#[tokio::test]
2026+
async fn partition_compaction_decimal96() {
2027+
Config::test("partition_compaction_decimal96")
2028+
.update_config(|mut c| {
2029+
c.partition_split_threshold = 20;
2030+
c
2031+
})
2032+
.start_test(async move |services| {
2033+
let service = services.sql_service;
2034+
let _ = service.exec_query("CREATE SCHEMA test").await.unwrap();
2035+
let compaction_service = services
2036+
.injector
2037+
.get_service_typed::<dyn CompactionService>()
2038+
.await;
2039+
service
2040+
.exec_query("create table test.a (a int, d0 decimal(20,0), d1 decimal(20, 1), d2 decimal(20, 2), d3 decimal(20, 3), d4 decimal(20, 4), d5 decimal(20, 5), d10 decimal(20, 10))")
2041+
.await
2042+
.unwrap();
2043+
let values = (0..15)
2044+
.map(|i| format!("({}, {}, {}, {}, {}, {}, {}, {})", i, i, i, i, i, i, i, i))
2045+
.collect::<Vec<_>>()
2046+
.join(", ");
2047+
let query = format!("insert into test.a (a, d0, d1, d2, d3, d4, d5, d10) values {}", values);
2048+
service.exec_query(&query).await.unwrap();
2049+
compaction_service
2050+
.compact(1, DataLoadedSize::new())
2051+
.await
2052+
.unwrap();
2053+
let partitions = services
2054+
.meta_store
2055+
.get_active_partitions_by_index_id(1)
2056+
.await
2057+
.unwrap();
2058+
assert_eq!(partitions.len(), 1);
2059+
let values = (0..30)
2060+
.map(|i| format!("({}, {}, {}, {}, {}, {}, {}, {})", i, i, i, i, i, i, i, i))
2061+
.collect::<Vec<_>>()
2062+
.join(", ");
2063+
let query = format!("insert into test.a (a, d0, d1, d2, d3, d4, d5, d10) values {}", values);
2064+
2065+
service.exec_query(&query).await.unwrap();
2066+
compaction_service
2067+
.compact(partitions[0].get_id(), DataLoadedSize::new())
2068+
.await
2069+
.unwrap();
2070+
let partitions = services
2071+
.meta_store
2072+
.get_active_partitions_by_index_id(1)
2073+
.await
2074+
.unwrap();
2075+
assert_eq!(partitions.len(), 3);
2076+
})
2077+
.await;
2078+
}
2079+
19692080
#[tokio::test]
19702081
async fn partition_split_by_file_size() {
19712082
Config::test("partition_split_by_file_size")

0 commit comments

Comments
 (0)