Skip to content

Commit 50a53e6

Browse files
committed
Fix total rollup schema bug
Signed-off-by: Andrew Stein <steinlink@gmail.com>
1 parent 539b19e commit 50a53e6

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

rust/perspective-js/test/js/group_rollup_mode.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,23 @@ const data = {
585585
table.delete();
586586
});
587587

588+
test("with split_by schema", async function () {
589+
const table = await perspective.table(data);
590+
const view = await table.view({
591+
split_by: ["z"],
592+
group_rollup_mode: "total",
593+
});
594+
const schema = await view.schema();
595+
expect(schema).toStrictEqual({
596+
w: "float",
597+
x: "integer",
598+
y: "integer",
599+
z: "integer",
600+
});
601+
view.delete();
602+
table.delete();
603+
});
604+
588605
test("updates after table.update()", async function () {
589606
const table = await perspective.table(data);
590607
const view = await table.view({

rust/perspective-server/cpp/perspective/src/cpp/view.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ View<CTX_T>::schema() const {
461461
std::string type_string = dtype_to_str(types[agg_name]);
462462
new_schema[agg_name] = type_string;
463463

464-
if ((!m_row_pivots.empty() || m_view_config->is_total_only()) && !is_column_only()) {
464+
if ((!m_row_pivots.empty() || m_view_config->is_total_only()) && (!is_column_only() || m_view_config->is_total_only())) {
465465
new_schema[agg_name] =
466466
_map_aggregate_types(agg_name, new_schema[agg_name]);
467467
}
@@ -540,7 +540,7 @@ View<CTX_T>::expression_schema() const {
540540
const std::string& expression_alias = expr->get_expression_alias();
541541
new_schema[expression_alias] = dtype_to_str(expr->get_dtype());
542542

543-
if ((!m_row_pivots.empty() || m_view_config->is_total_only()) && !is_column_only()) {
543+
if ((!m_row_pivots.empty() || m_view_config->is_total_only()) && (!is_column_only() || m_view_config->is_total_only())) {
544544
new_schema[expression_alias] = _map_aggregate_types(
545545
expression_alias, new_schema[expression_alias]
546546
);

0 commit comments

Comments
 (0)