Skip to content

Commit be1f233

Browse files
authored
fix(query): fix string view memory size calculate error (#17629)
* fix(query): fix string view memory size calculate error * fix * fix * fix * fix * fix tests * fix tests
1 parent 97b0692 commit be1f233

File tree

10 files changed

+24
-13
lines changed

10 files changed

+24
-13
lines changed

src/common/column/src/binview/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl<T: ViewType + ?Sized> BinaryViewColumnGeneric<T> {
297297
}
298298

299299
pub fn memory_size(&self) -> usize {
300-
self.total_buffer_len() + self.len() * 12
300+
self.total_bytes_len() + self.len() * 12
301301
}
302302

303303
fn total_unshared_buffer_len(&self) -> usize {

src/common/column/tests/it/binview/mod.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,25 @@ fn from_iter() {
113113

114114
#[test]
115115
fn test_slice() {
116-
let data = vec!["hello", "world", "databend", "y", "z", "abc"];
116+
let data = vec![
117+
"hello",
118+
"world",
119+
"databend",
120+
"yyyyyyyyyyyyyyyyyyyyy",
121+
"zzzzzzzzzzzzzzzzzzzzz",
122+
"abcabcabcabcabcabc",
123+
];
117124

118125
let array: Utf8ViewColumn = data.into_iter().collect();
126+
assert_eq!(array.memory_size(), 150);
119127

120128
let a3 = array.sliced(2, 3);
121129
assert_eq!(a3.into_iter().collect::<Vec<_>>(), vec![
122-
"databend", "y", "z"
130+
"databend",
131+
"yyyyyyyyyyyyyyyyyyyyy",
132+
"zzzzzzzzzzzzzzzzzzzzz",
123133
]);
134+
assert_eq!(a3.memory_size(), 86);
124135
}
125136

126137
#[test]

tests/sqllogictests/suites/base/20+_others/20_0013_query_result_cache.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ EXPLAIN SELECT * FROM t1, t2 ORDER BY a, b;
8989
ReadQueryResultCache
9090
├── SQL: SELECT * FROM t1, t2 ORDER BY a, b
9191
├── Number of rows: 9
92-
└── Result size: 144
92+
└── Result size: 153
9393

9494

9595

tests/suites/1_stateful/00_stage/00_0001_copy_into_stage.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
2
1010
2
1111
20 160
12-
20 530
12+
20 450
1313
2
1414
20 160

tests/suites/1_stateful/05_formats/05_05_parquet/05_05_01_parquet_load_unload.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ a"b 1 ['a"b'] {"k":"v"} 2044-05-06 10:25:02.868894 10.01 ('a',5) ['{"k":"v"}'] [
2929
NULL 2 ['a'b'] [1] 2044-05-06 10:25:02.868894 -10.01 ('b',10) ['[1]'] [('b',10)]
3030
<<<<
3131
>>>> copy into @s1/unload1/ from test_load_unload
32-
2 390
32+
2 362
3333
>>>> truncate table test_load_unload
3434
>>>> copy into test_load_unload from @s1/unload1.parquet force=true;
3535
unload1.parquet 2 0 NULL NULL
3636
begin diff select
3737
end diff
3838
>>>> copy into @s1/unload2/ from test_load_unload
39-
2 390
39+
2 362
4040
begin diff parquet
4141
end diff
4242
>>>> truncate table test_load_unload

tests/suites/1_stateful/07_stage_attachment/07_0000_insert_with_stage.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
sample.csv
22
Succeeded
33
96
4-
192
4+
281
55
null
66
1 'Beijing' 100 China
77
2 'Shanghai' 80 China

tests/suites/1_stateful/07_stage_attachment/07_0001_replace_with_stage.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sample.csv
22
96
3-
192
3+
281
44
null
55
1 'Beijing' 100 China
66
2 'Shanghai' 80 China

tests/suites/1_stateful/07_stage_attachment/07_0002_insert_with_stage_deduplicate.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sample.csv
22
96
3-
192
3+
281
44
null
55
1 'Beijing' 100 China
66
2 'Shanghai' 80 China

tests/suites/1_stateful/07_stage_attachment/07_0003_insert_with_stage_file_format.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<<<<
88
Succeeded
99
20
10-
27
10+
31
1111
null
1212
>>>> list @s1
1313
<<<<

tests/suites/1_stateful/08_select_stage/08_00_parquet/08_00_00_basic.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
2
22
--- named internal stage
3-
2 53
3+
2 45
44
1 2 3
55
4 5 6
6-
2 53
6+
2 45
77
--- external stage
88
1 2 3
99
4 5 6

0 commit comments

Comments
 (0)