Skip to content

Commit

Permalink
Attribute fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpwright committed Mar 4, 2025
1 parent a3a3e23 commit 7f1950f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,9 @@ public RollupTableImpl rebase(@NotNull final Table newSource) {
newSourceQueryTable = (QueryTable) newSource.coalesce();
}

return makeRollupInternal(newSourceQueryTable, aggregations, includesConstituents, groupByColumns,
return makeRollupInternal(
getAttributes(),
newSourceQueryTable, aggregations, includesConstituents, groupByColumns,
aggregatedNodeDefinition, aggregatedNodeOperations, constituentNodeDefinition,
constituentNodeOperations,
availableColumnDefinitions);
Expand All @@ -510,16 +512,18 @@ public static RollupTable makeRollup(
@NotNull final Collection<? extends Aggregation> aggregations,
final boolean includeConstituents,
@NotNull final Collection<? extends ColumnName> groupByColumns) {
final RollupTableImpl result = makeRollupInternal(source, aggregations, includeConstituents, groupByColumns,
null, null, null, null, null);
final RollupTableImpl result =
makeRollupInternal(source.getAttributes(ak -> shouldCopyAttribute(ak, CopyAttributeOperation.Rollup)),
source, aggregations, includeConstituents, groupByColumns,
null, null, null, null, null);
final TableDefinition baseDefinition = result.levelTables[groupByColumns.size()].getDefinition();
source.copySortableColumns(result, baseDefinition.getColumnNameSet()::contains);
result.setColumnDescriptions(AggregationDescriptions.of(aggregations));
return result;
}

private static @NotNull RollupTableImpl makeRollupInternal(
@NotNull final QueryTable source,
@NotNull final Map<String, Object> attributes, @NotNull final QueryTable source,
@NotNull final Collection<? extends Aggregation> aggregations,
final boolean includeConstituents,
@NotNull final Collection<? extends ColumnName> groupByColumns,
Expand All @@ -539,7 +543,7 @@ public static RollupTable makeRollup(
rollupFromBase(levelTables, levelRowLookups, levelNodeTableSources, aggregations, groupByColumns);

return new RollupTableImpl(
source.getAttributes(ak -> shouldCopyAttribute(ak, CopyAttributeOperation.Rollup)),
attributes,
source, aggregations, includeConstituents, groupByColumns,
levelTables, levelRowLookups, levelNodeTableSources, aggregatedNodeDefinition, aggregatedNodeOperations,
constituentNodeDefinition, constituentNodeOperations, null, availableColumnDefinitions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ public void testRebase() {
final Table source2 =
TableTools.newTable(stringCol("A", "Echo", "Foxtrot", "Golf", "Hotel"), intCol("Sentinel", 6, 7, 8, 9));

final RollupTable rebased = rollup1.rebase(source2);
final RollupTable attributeCheck = rollup1.withAttributes(Collections.singletonMap("Haustier", "Kammerhunde"));

final RollupTable rebased = attributeCheck.rebase(source2);

final HierarchicalTable.SnapshotState ss2 = rebased.makeSnapshotState();
final Table snapshot2 =
Expand All @@ -170,6 +172,7 @@ public void testRebase() {
snapshot2.view("A", "Count"));
freeSnapshotTableChunks(snapshot2);

assertEquals("Kammerhunde", rebased.getAttribute("Haustier"));
}

@Test
Expand Down

0 comments on commit 7f1950f

Please sign in to comment.