File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
crates/duckdb/src/appender Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -103,17 +103,20 @@ mod test {
103
103
let db = Connection :: open_in_memory ( ) ?;
104
104
db. execute_batch ( "CREATE TABLE foo(id INT)" ) ?;
105
105
{
106
- let id_array = Int32Array :: from ( vec ! [ 42 ; record_count] ) ;
106
+ let id_array = Int32Array :: from ( ( 0 .. record_count as i32 ) . collect :: < Vec < _ > > ( ) ) ;
107
107
let schema = Schema :: new ( vec ! [ Field :: new( "id" , DataType :: Int32 , true ) ] ) ;
108
108
let record_batch = RecordBatch :: try_new ( Arc :: new ( schema) , vec ! [ Arc :: new( id_array) ] ) . unwrap ( ) ;
109
109
let mut app = db. appender ( "foo" ) ?;
110
110
app. append_record_batch ( record_batch) ?;
111
111
}
112
- let count = db. query_row ( "SELECT COUNT(*) FROM foo" , [ ] , |row| {
113
- let count: usize = row. get ( 0 ) ?;
114
- Ok ( count)
115
- } ) ?;
112
+ let count: usize = db. query_row ( "SELECT COUNT(*) FROM foo" , [ ] , |row| row. get ( 0 ) ) ?;
116
113
assert_eq ! ( count, record_count) ;
114
+
115
+ // Verify the data is correct
116
+ let sum: i64 = db. query_row ( "SELECT SUM(id) FROM foo" , [ ] , |row| row. get ( 0 ) ) ?;
117
+ let expected_sum = ( 0 ..record_count as i64 ) . sum ( ) ;
118
+ assert_eq ! ( sum, expected_sum) ;
119
+
117
120
Ok ( ( ) )
118
121
}
119
122
}
You can’t perform that action at this time.
0 commit comments