1313import io .deephaven .engine .table .Table ;
1414import io .deephaven .engine .table .hierarchical .HierarchicalTable ;
1515import io .deephaven .engine .table .hierarchical .RollupTable ;
16+ import io .deephaven .engine .table .impl .util .ColumnHolder ;
1617import io .deephaven .engine .testutil .ColumnInfo ;
1718import io .deephaven .engine .testutil .ControlledUpdateGraph ;
1819import io .deephaven .engine .testutil .EvalNuggetInterface ;
2526import io .deephaven .test .types .OutOfBandTest ;
2627import io .deephaven .vector .IntVector ;
2728import io .deephaven .vector .IntVectorDirect ;
29+ import io .deephaven .vector .LongVector ;
30+ import io .deephaven .vector .LongVectorDirect ;
2831import org .jspecify .annotations .NonNull ;
2932import org .junit .Assert ;
3033import org .junit .Test ;
@@ -424,7 +427,6 @@ public void testRollupFormulaStatic2() {
424427 stringCol ("Sym" , "leg1" , "leg2" , "leg1" , "leg2" ),
425428 intCol ("qty" , 100 , 100 , 200 , 200 ),
426429 doubleCol ("Dollars" , 1000 , -500 , 2000 , -1000 ));
427- TableTools .show (source );
428430
429431 final RollupTable rollup1 =
430432 source .updateView ("qty=(long)qty" ).rollup (
@@ -442,10 +444,15 @@ public void testRollupFormulaStatic2() {
442444 final HierarchicalTable .SnapshotState ss1 = rollup1 .makeSnapshotState ();
443445 final Table snapshot =
444446 snapshotToTable (rollup1 , ss1 , keyTable , ColumnName .of ("Action" ), null , RowSetFactory .flat (30 ));
445- TableTools .showWithRowSet (snapshot );
446447
447- // final Table expected = initialExpectedGrouped(rollup1).update("FSum=ii == 0 ? 7 : 1 + Sum");
448- // assertTableEquals(expected, snapshot);
448+ final Table expected = TableTools .newTable (intCol (rollup1 .getRowDepthColumn ().name (), 1 , 2 , 3 , 3 , 2 , 3 , 3 ),
449+ booleanCol (rollup1 .getRowExpandedColumn ().name (), true , true , null , null , true , null , null ),
450+ col ("Account" , null , "acct1" , "acct1" , "acct1" , "acct2" , "acct2" , "acct2" ),
451+ col ("Sym" , null , null , "leg1" , "leg2" , null , "leg1" , "leg2" ),
452+ longCol ("qty" , 300 , 100 , 100 , 100 , 200 , 200 , 200 ),
453+ doubleCol ("Dollars" , 1500 , 500 , 1000 , -500 , 1000 , 2000 , -1000 ));
454+
455+ assertTableEquals (expected , snapshot );
449456 freeSnapshotTableChunks (snapshot );
450457 }
451458
@@ -492,8 +499,27 @@ private void testRollupFormulaStatic3(boolean hasGroup) {
492499 snapshotToTable (rollup2 , ss1 , keyTable , ColumnName .of ("Action" ), null , RowSetFactory .flat (30 ));
493500 TableTools .showWithRowSet (snapshot );
494501
495- // final Table expected = initialExpectedGrouped(rollup1).update("FSum=ii == 0 ? 7 : 1 + Sum");
496- // assertTableEquals(expected, snapshot);
502+ final List <ColumnHolder <?>> columnHolders = new ArrayList <>();
503+ columnHolders .add (intCol (rollup1 .getRowDepthColumn ().name (), 1 , 2 , 3 , 3 , 2 , 3 , 2 , 3 , 3 ));
504+ columnHolders .add (booleanCol (rollup1 .getRowExpandedColumn ().name (), true , true , null , null , true , null , true ,
505+ null , null ));
506+ columnHolders .add (stringCol ("Account" , null , "Aardvark" , "Aardvark" , "Aardvark" , "Badger" , "Badger" , "Cobra" ,
507+ "Cobra" , "Cobra" ));
508+ columnHolders
509+ .add (stringCol ("Sym" , null , null , "Apple" , "Banana" , null , "Carrot" , null , "Apple" , "Dragonfruit" ));
510+ columnHolders .add (col ("gqty" , lv (500 , 100 , 500 , 200 , 300 , 300 , 200 , 100 , 200 , 300 , 1500 ),
511+ /* aardvark */ lv (500 , 100 , 500 , 200 ), lv (500 , 500 , 200 ), lv (100 ), /* badger */ lv (300 , 300 , 200 ),
512+ lv (300 , 300 , 200 ), /* cobra */ lv (100 , 200 , 300 , 1500 ), lv (100 , 200 , 300 ), lv (1500 )));
513+ columnHolders .add (longCol ("qty" , 3500 , /* aardvark */ 1100 , 1000 , 100 , /* badger */ 800 , 800 , /* cobra */ 1600 ,
514+ 600 , 1000 ));
515+ final Table expected = TableTools .newTable (columnHolders .toArray (ColumnHolder []::new ))
516+ .update ("sqty = sum(gqty)" , "SumDiff=sqty-qty" );
517+
518+ TableTools .show (expected );
519+
520+ assertTableEquals (hasGroup ? expected : expected .dropColumns ("gqty" ),
521+ hasGroup ? snapshot .dropColumns ("__EXPOSED_GROUP_ROW_SETS__" ) : snapshot );
522+
497523 freeSnapshotTableChunks (snapshot );
498524 }
499525
@@ -523,6 +549,10 @@ private static Table secondExpectedGrouped(RollupTable rollup1) {
523549 return new IntVectorDirect (ints );
524550 }
525551
552+ private static @ NonNull LongVector lv (final long ... ints ) {
553+ return new LongVectorDirect (ints );
554+ }
555+
526556 @ Test
527557 public void testRollupGroupIncremental () {
528558 final QueryTable source = TstUtils .testRefreshingTable (
@@ -610,6 +640,5 @@ public void testReusedGrouping() {
610640 TableTools .showWithRowSet (expected2 );
611641 assertTableEquals (expected2 , snapshot2 .dropColumns ("__EXPOSED_GROUP_ROW_SETS__" ));
612642 freeSnapshotTableChunks (snapshot2 );
613- // TODO: modify only one column, validate that we get results that we expect without excess modifications
614643 }
615644}
0 commit comments