You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by ma...@apache.org on 2025/01/24 11:08:52 UTC

(cloudberry) 28/30: Fix wrong number of maxAttrNum in TupleSplitState (#14927)

This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 7bc6fd48e67478c7084e19c866a267b68782a67a
Author: Haotian Chen <10...@users.noreply.github.com>
AuthorDate: Fri Mar 10 16:59:39 2023 +0800

    Fix wrong number of maxAttrNum in TupleSplitState (#14927)
    
    we cannot get corrent number of projecting targets for executing TupleSplit Node
    if wrong maxAttrNum in TupleSplitState, that cause wrong results in multi-dqa sql.
    ```
    select count(distinct a), count(distinct b) from dqa_f4 group by c;
    ```
    For each splited tuple, we also need to project column `c` as group column besides
    distinct column `a` and `b`. As a result, toal maxAttrNum of TupleSplit is three instead of two,
    which also decided totals projection columns of Node Tuplesplit.
    To figure maxAttrNum correctly, we need to calculate again after we initiated all elements
    in TupleSplitState.
---
 src/backend/executor/nodeTupleSplit.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/backend/executor/nodeTupleSplit.c b/src/backend/executor/nodeTupleSplit.c
index 85a9f3ecab..638bf8e76e 100644
--- a/src/backend/executor/nodeTupleSplit.c
+++ b/src/backend/executor/nodeTupleSplit.c
@@ -103,8 +103,6 @@ ExecInitTupleSplit(TupleSplit *node, EState *estate, int eflags)
 		i ++;
 	}
 
-	tup_spl_state->maxAttrNum = maxAttrNum;
-
 	/*
 	 * fetch group by expr bitmap set
 	 */
@@ -146,6 +144,15 @@ ExecInitTupleSplit(TupleSplit *node, EState *estate, int eflags)
 		bms_free(orig_bms);
 	}
 
+	/*
+	 * Update maxAttrNum which is used to calculate projection number
+	 * of ExecTupleSplit
+	 */
+	int x = bms_prev_member(skip_split_bms, -1);
+	if (x > maxAttrNum)
+		maxAttrNum = x;
+	tup_spl_state->maxAttrNum = maxAttrNum;
+
 	bms_free(skip_split_bms);
 
 	return tup_spl_state;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org