1
1
import * as arrow from 'apache-arrow' ;
2
2
import * as pb from '@ankoh/dashql-protobuf' ;
3
+ import * as buf from "@bufbuild/protobuf" ;
3
4
4
5
import { VariantKind } from '../utils/variant.js' ;
5
6
import { AsyncDataFrame } from './compute_worker_bindings.js' ;
@@ -330,7 +331,7 @@ export function createTableSummaryTransform(task: TableSummaryTask): [pb.dashql.
330
331
331
332
// Add count(*) aggregate
332
333
const countColumn = `_count` ;
333
- aggregates . push ( new pb . dashql . compute . GroupByAggregate ( {
334
+ aggregates . push ( buf . create ( pb . dashql . compute . GroupByAggregateSchema , {
334
335
outputAlias : `_count` ,
335
336
aggregationFunction : pb . dashql . compute . AggregationFunction . CountStar ,
336
337
} ) ) ;
@@ -348,17 +349,17 @@ export function createTableSummaryTransform(task: TableSummaryTask): [pb.dashql.
348
349
const countAggregateColumn = `_${ i } _count` ;
349
350
const minAggregateColumn = `_${ i } _min` ;
350
351
const maxAggregateColumn = `_${ i } _max` ;
351
- aggregates . push ( new pb . dashql . compute . GroupByAggregate ( {
352
+ aggregates . push ( buf . create ( pb . dashql . compute . GroupByAggregateSchema , {
352
353
fieldName : entry . value . inputFieldName ,
353
354
outputAlias : countAggregateColumn ,
354
355
aggregationFunction : pb . dashql . compute . AggregationFunction . Count ,
355
356
} ) ) ;
356
- aggregates . push ( new pb . dashql . compute . GroupByAggregate ( {
357
+ aggregates . push ( buf . create ( pb . dashql . compute . GroupByAggregateSchema , {
357
358
fieldName : entry . value . inputFieldName ,
358
359
outputAlias : minAggregateColumn ,
359
360
aggregationFunction : pb . dashql . compute . AggregationFunction . Min ,
360
361
} ) ) ;
361
- aggregates . push ( new pb . dashql . compute . GroupByAggregate ( {
362
+ aggregates . push ( buf . create ( pb . dashql . compute . GroupByAggregateSchema , {
362
363
fieldName : entry . value . inputFieldName ,
363
364
outputAlias : maxAggregateColumn ,
364
365
aggregationFunction : pb . dashql . compute . AggregationFunction . Max ,
@@ -381,12 +382,12 @@ export function createTableSummaryTransform(task: TableSummaryTask): [pb.dashql.
381
382
case STRING_COLUMN : {
382
383
const countAggregateColumn = `_${ i } _count` ;
383
384
const countDistinctAggregateColumn = `_${ i } _countd` ;
384
- aggregates . push ( new pb . dashql . compute . GroupByAggregate ( {
385
+ aggregates . push ( buf . create ( pb . dashql . compute . GroupByAggregateSchema , {
385
386
fieldName : entry . value . inputFieldName ,
386
387
outputAlias : countAggregateColumn ,
387
388
aggregationFunction : pb . dashql . compute . AggregationFunction . Count ,
388
389
} ) ) ;
389
- aggregates . push ( new pb . dashql . compute . GroupByAggregate ( {
390
+ aggregates . push ( buf . create ( pb . dashql . compute . GroupByAggregateSchema , {
390
391
fieldName : entry . value . inputFieldName ,
391
392
outputAlias : countDistinctAggregateColumn ,
392
393
aggregationFunction : pb . dashql . compute . AggregationFunction . Count ,
@@ -410,12 +411,12 @@ export function createTableSummaryTransform(task: TableSummaryTask): [pb.dashql.
410
411
case LIST_COLUMN : {
411
412
const countAggregateColumn = `_${ i } _count` ;
412
413
const countDistinctAggregateColumn = `_${ i } _countd` ;
413
- aggregates . push ( new pb . dashql . compute . GroupByAggregate ( {
414
+ aggregates . push ( buf . create ( pb . dashql . compute . GroupByAggregateSchema , {
414
415
fieldName : entry . value . inputFieldName ,
415
416
outputAlias : countAggregateColumn ,
416
417
aggregationFunction : pb . dashql . compute . AggregationFunction . Count ,
417
418
} ) ) ;
418
- aggregates . push ( new pb . dashql . compute . GroupByAggregate ( {
419
+ aggregates . push ( buf . create ( pb . dashql . compute . GroupByAggregateSchema , {
419
420
fieldName : entry . value . inputFieldName ,
420
421
outputAlias : countDistinctAggregateColumn ,
421
422
aggregationFunction : pb . dashql . compute . AggregationFunction . Count ,
@@ -438,8 +439,8 @@ export function createTableSummaryTransform(task: TableSummaryTask): [pb.dashql.
438
439
}
439
440
}
440
441
}
441
- const transform = new pb . dashql . compute . DataFrameTransform ( {
442
- groupBy : new pb . dashql . compute . GroupByTransform ( {
442
+ const transform = buf . create ( pb . dashql . compute . DataFrameTransformSchema , {
443
+ groupBy : buf . create ( pb . dashql . compute . GroupByTransformSchema , {
443
444
keys : [ ] ,
444
445
aggregates
445
446
} )
@@ -459,13 +460,13 @@ export function createColumnSummaryTransform(task: ColumnSummaryTask): pb.dashql
459
460
case ORDINAL_COLUMN : {
460
461
const minField = task . columnEntry . value . statsFields . minAggregateFieldName ! ;
461
462
const maxField = task . columnEntry . value . statsFields . maxAggregateFieldName ! ;
462
- out = new pb . dashql . compute . DataFrameTransform ( {
463
- groupBy : new pb . dashql . compute . GroupByTransform ( {
463
+ out = buf . create ( pb . dashql . compute . DataFrameTransformSchema , {
464
+ groupBy : buf . create ( pb . dashql . compute . GroupByTransformSchema , {
464
465
keys : [
465
- new pb . dashql . compute . GroupByKey ( {
466
+ buf . create ( pb . dashql . compute . GroupByKeySchema , {
466
467
fieldName,
467
468
outputAlias : "bin" ,
468
- binning : new pb . dashql . compute . GroupByKeyBinning ( {
469
+ binning : buf . create ( pb . dashql . compute . GroupByKeyBinningSchema , {
469
470
statsMinimumFieldName : minField ,
470
471
statsMaximumFieldName : maxField ,
471
472
binCount : BIN_COUNT ,
@@ -476,16 +477,16 @@ export function createColumnSummaryTransform(task: ColumnSummaryTask): pb.dashql
476
477
} )
477
478
] ,
478
479
aggregates : [
479
- new pb . dashql . compute . GroupByAggregate ( {
480
+ buf . create ( pb . dashql . compute . GroupByAggregateSchema , {
480
481
fieldName,
481
482
outputAlias : "count" ,
482
483
aggregationFunction : pb . dashql . compute . AggregationFunction . CountStar ,
483
484
} )
484
485
]
485
486
} ) ,
486
- orderBy : new pb . dashql . compute . OrderByTransform ( {
487
+ orderBy : buf . create ( pb . dashql . compute . OrderByTransformSchema , {
487
488
constraints : [
488
- new pb . dashql . compute . OrderByConstraint ( {
489
+ buf . create ( pb . dashql . compute . OrderByConstraintSchema , {
489
490
fieldName : "bin" ,
490
491
ascending : true ,
491
492
nullsFirst : false ,
@@ -497,25 +498,25 @@ export function createColumnSummaryTransform(task: ColumnSummaryTask): pb.dashql
497
498
}
498
499
case LIST_COLUMN :
499
500
case STRING_COLUMN : {
500
- out = new pb . dashql . compute . DataFrameTransform ( {
501
- groupBy : new pb . dashql . compute . GroupByTransform ( {
501
+ out = buf . create ( pb . dashql . compute . DataFrameTransformSchema , {
502
+ groupBy : buf . create ( pb . dashql . compute . GroupByTransformSchema , {
502
503
keys : [
503
- new pb . dashql . compute . GroupByKey ( {
504
+ buf . create ( pb . dashql . compute . GroupByKeySchema , {
504
505
fieldName,
505
506
outputAlias : "key" ,
506
507
} )
507
508
] ,
508
509
aggregates : [
509
- new pb . dashql . compute . GroupByAggregate ( {
510
+ buf . create ( pb . dashql . compute . GroupByAggregateSchema , {
510
511
fieldName,
511
512
outputAlias : "count" ,
512
513
aggregationFunction : pb . dashql . compute . AggregationFunction . CountStar ,
513
514
} )
514
515
]
515
516
} ) ,
516
- orderBy : new pb . dashql . compute . OrderByTransform ( {
517
+ orderBy : buf . create ( pb . dashql . compute . OrderByTransformSchema , {
517
518
constraints : [
518
- new pb . dashql . compute . OrderByConstraint ( {
519
+ buf . create ( pb . dashql . compute . OrderByConstraintSchema , {
519
520
fieldName : "count" ,
520
521
ascending : false ,
521
522
nullsFirst : false ,
@@ -531,8 +532,8 @@ export function createColumnSummaryTransform(task: ColumnSummaryTask): pb.dashql
531
532
}
532
533
533
534
export function createOrderByTransform ( constraints : pb . dashql . compute . OrderByConstraint [ ] , limit ?: number ) : pb . dashql . compute . DataFrameTransform {
534
- const out = new pb . dashql . compute . DataFrameTransform ( {
535
- orderBy : new pb . dashql . compute . OrderByTransform ( {
535
+ const out = buf . create ( pb . dashql . compute . DataFrameTransformSchema , {
536
+ orderBy : buf . create ( pb . dashql . compute . OrderByTransformSchema , {
536
537
constraints,
537
538
limit
538
539
} )
@@ -566,7 +567,7 @@ export function createPrecomputationTransform(schema: arrow.Schema, columns: Gri
566
567
567
568
// Prepend the row number column at position 0
568
569
const rowNumberFieldName = createUniqueColumnName ( `_rownum` , fieldNames ) ;
569
- const rowNumberTransform = new pb . dashql . compute . RowNumberTransform ( {
570
+ const rowNumberTransform = buf . create ( pb . dashql . compute . RowNumberTransformSchema , {
570
571
outputAlias : rowNumberFieldName
571
572
} ) ;
572
573
const rowNumberGridColumn : GridColumnGroup = {
@@ -590,7 +591,7 @@ export function createPrecomputationTransform(schema: arrow.Schema, columns: Gri
590
591
case ORDINAL_COLUMN : {
591
592
const binFieldId = nextOutputColumn ++ ;
592
593
const binFieldName = createUniqueColumnName ( `_${ i } _bin` , fieldNames ) ;
593
- binningTransforms . push ( new pb . dashql . compute . BinningTransform ( {
594
+ binningTransforms . push ( buf . create ( pb . dashql . compute . BinningTransformSchema , {
594
595
fieldName : column . value . inputFieldName ,
595
596
statsMaximumFieldName : column . value . statsFields ! . maxAggregateFieldName ! ,
596
597
statsMinimumFieldName : column . value . statsFields ! . minAggregateFieldName ! ,
@@ -608,7 +609,7 @@ export function createPrecomputationTransform(schema: arrow.Schema, columns: Gri
608
609
}
609
610
case STRING_COLUMN : {
610
611
const valueFieldName = createUniqueColumnName ( `_${ i } _id` , fieldNames ) ;
611
- identifierTransforms . push ( new pb . dashql . compute . ValueIdentifierTransform ( {
612
+ identifierTransforms . push ( buf . create ( pb . dashql . compute . ValueIdentifierTransformSchema , {
612
613
fieldName : column . value . inputFieldName ,
613
614
outputAlias : valueFieldName
614
615
} ) ) ;
@@ -623,7 +624,7 @@ export function createPrecomputationTransform(schema: arrow.Schema, columns: Gri
623
624
}
624
625
case LIST_COLUMN : {
625
626
const valueFieldName = createUniqueColumnName ( `_${ i } _id` , fieldNames ) ;
626
- identifierTransforms . push ( new pb . dashql . compute . ValueIdentifierTransform ( {
627
+ identifierTransforms . push ( buf . create ( pb . dashql . compute . ValueIdentifierTransformSchema , {
627
628
fieldName : column . value . inputFieldName ,
628
629
outputAlias : valueFieldName
629
630
} ) ) ;
@@ -639,17 +640,17 @@ export function createPrecomputationTransform(schema: arrow.Schema, columns: Gri
639
640
}
640
641
}
641
642
642
- const ordering = new pb . dashql . compute . OrderByTransform ( {
643
+ const ordering = buf . create ( pb . dashql . compute . OrderByTransformSchema , {
643
644
constraints : [
644
- new pb . dashql . compute . OrderByConstraint ( {
645
+ buf . create ( pb . dashql . compute . OrderByConstraintSchema , {
645
646
fieldName : rowNumberFieldName ,
646
647
ascending : true ,
647
648
nullsFirst : false
648
649
} )
649
650
]
650
651
} ) ;
651
652
652
- const transform = new pb . dashql . compute . DataFrameTransform ( {
653
+ const transform = buf . create ( pb . dashql . compute . DataFrameTransformSchema , {
653
654
rowNumber : rowNumberTransform ,
654
655
valueIdentifiers : identifierTransforms ,
655
656
binning : binningTransforms ,
0 commit comments