File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ console.log(table.schema);
1313const batch = table . recordBatch ( 0 ) ;
1414
1515console . log ( batch . numRows ) ;
16+ console . log ( batch . columns [ 3 ] ) ;
1617console . log ( batch . numColumns ) ;
1718console . log ( batch . schema . toJSON ( ) ) ;
1819console . log ( batch . schema . fields ) ;
Original file line number Diff line number Diff line change 1+ const arrow_wasm = require ( "../pkg/arrow_wasm" ) ;
2+
3+ const schema = arrow_wasm . Schema . from ( {
4+ fields : [
5+ {
6+ name : "number" ,
7+ nullable : false ,
8+ type : {
9+ name : "int" ,
10+ isSigned : true ,
11+ bitWidth : 32 ,
12+ } ,
13+ } ,
14+ ] ,
15+ } ) ;
16+
17+ console . log ( schema . toJSON ( ) ) ;
Original file line number Diff line number Diff line change 11use crate :: { schema, vector} ;
2+ use js_sys:: Array ;
23use wasm_bindgen:: prelude:: * ;
34
45#[ wasm_bindgen]
@@ -27,6 +28,20 @@ impl RecordBatch {
2728 vector:: Vector :: new ( self . 0 . column ( index) . clone ( ) )
2829 }
2930
31+ /// Get all columns in the record batch.
32+ // TODO: specify that the output type is Array<Vector>, not Array<any>
33+ #[ wasm_bindgen( getter) ]
34+ pub fn columns ( & self ) -> Array {
35+ let vectors: Vec < vector:: Vector > = self
36+ . 0
37+ . columns ( )
38+ . into_iter ( )
39+ . map ( |column| vector:: Vector :: new ( column. clone ( ) ) )
40+ . collect ( ) ;
41+
42+ vectors. into_iter ( ) . map ( JsValue :: from) . collect ( )
43+ }
44+
3045 /// Get a column's vector by name.
3146 #[ wasm_bindgen( js_name = columnWithName) ]
3247 pub fn column_with_name ( & self , name : & str ) -> Result < crate :: vector:: Vector , JsValue > {
You can’t perform that action at this time.
0 commit comments