File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ import { Col, Predicate } from './predicate';
2020import { Schema , Field , Struct } from './type' ;
2121import { read , readAsync } from './ipc/reader/arrow' ;
2222import { isPromise , isAsyncIterable } from './util/compat' ;
23- import { Vector , DictionaryVector , IntVector } from './vector' ;
23+ import { Vector , DictionaryVector , IntVector , StructVector } from './vector' ;
24+ import { ChunkedView } from './vector/chunked' ;
2425
2526export type NextFunc = ( idx : number , cols : RecordBatch ) => void ;
2627
@@ -61,6 +62,13 @@ export class Table implements DataFrame {
6162 }
6263 return Table . empty ( ) ;
6364 }
65+ static fromStruct ( struct : StructVector ) {
66+ const schema = new Schema ( struct . type . children ) ;
67+ const chunks = struct . view instanceof ChunkedView ?
68+ ( struct . view . childVectors as StructVector [ ] ) :
69+ [ struct ] ;
70+ return new Table ( chunks . map ( ( chunk ) => new RecordBatch ( schema , chunk . length , chunk . view . childData ) ) ) ;
71+ }
6472
6573 public readonly schema : Schema ;
6674 public readonly length : number ;
You can’t perform that action at this time.
0 commit comments