Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sum aggregate to force re-agg for expression columns #1793

Merged
merged 1 commit into from
May 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cpp/perspective/src/cpp/sparse_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,13 +955,16 @@ void
t_stree::update_agg_table(t_uindex nidx, t_agg_update_info& info,
t_uindex src_ridx, t_uindex dst_ridx, t_index nstrands,
const t_gstate& gstate, const t_data_table& expression_master_table) {
const t_schema& expression_schema = expression_master_table.get_schema();

for (t_uindex idx : info.m_dst_topo_sorted) {
const t_column* src = info.m_src[idx];
t_column* dst = info.m_dst[idx];
const t_aggspec& spec = info.m_aggspecs[idx];
t_tscalar new_value = mknone();
t_tscalar old_value = mknone();
auto is_expr
= expression_schema.has_column(spec.get_dependencies()[0].name());

switch (spec.agg()) {
case AGGTYPE_PCT_SUM_PARENT:
Expand All @@ -971,9 +974,9 @@ t_stree::update_agg_table(t_uindex nidx, t_agg_update_info& info,
t_tscalar dst_scalar = dst->get_scalar(dst_ridx);
old_value.set(dst_scalar);
new_value.set(dst_scalar.add(src_scalar));
if (old_value
.is_nan()) // is_nan returns false for non-float types
{

// is_nan returns false for non-float types
if (is_expr || old_value.is_nan()) {
// if we previously had a NaN, add can't make it finite
// again; recalculate entire sum in case it is now finite
auto pkeys = get_pkeys(nidx);
Expand Down