khannaekta commented on code in PR #582: URL: https://github.com/apache/madlib/pull/582#discussion_r896285007
########## src/ports/postgres/modules/utilities/in_mem_group_control.py_in: ########## @@ -549,40 +550,43 @@ class GroupIterationController: self.iteration = self.iteration + 1 group_param = self.group_param - run_sql = """ - SELECT - {_grp_key} AS {col_grp_key}, - {grouping_col}, - {iteration} AS {col_grp_iteration}, - ({newState}) AS {col_grp_state} - FROM ( - SELECT *, - array_to_string(ARRAY[{grouping_str}], ',') AS {col_grp_key} - FROM {rel_source} - ) AS {as_rel_source} - JOIN ( {select_rel_state} ) AS {rel_state} - {using_str} - JOIN ( {select_n_tuples} ) AS _rel_n_tuples - {using_str} - {groupby_str} - """.format( - newState=newState, - iteration=self.iteration, - using_str=group_param.using_str, - groupby_str=group_param.groupby_str, - _grp_key=group_param.grp_key, - select_rel_state=group_param.select_rel_state, - select_n_tuples=group_param.select_n_tuples, - **self.kwargs) - update_plan = plpy.prepare(run_sql, - ["text[]", group_param.grouped_state_type, - "text[]", "integer[]"]) - res_tuples = plpy.execute(update_plan, [self.new_states.keys, - self.new_states.values, - self.grp_to_n_tuples.keys(), - self.grp_to_n_tuples.values()]) + if self.update_plan is None: + run_sql = """ + SELECT + {_grp_key} AS {col_grp_key}, + {grouping_col}, + ({newState}) AS {col_grp_state} + FROM ( + SELECT *, + array_to_string(ARRAY[{grouping_str}], ',') AS {col_grp_key} + FROM {rel_source} + ) AS {as_rel_source} + JOIN ( {select_rel_state} ) AS {rel_state} + {using_str} + JOIN ( {select_n_tuples} ) AS _rel_n_tuples + {using_str} + {groupby_str} + """.format( + newState=newState, + iteration=self.iteration, + using_str=group_param.using_str, + groupby_str=group_param.groupby_str, + _grp_key=group_param.grp_key, + select_rel_state=group_param.select_rel_state, + select_n_tuples=group_param.select_n_tuples, + **self.kwargs) + + self.update_plan = plpy.prepare(run_sql, Review Comment: For `plpy.prepare()` statement, don't we want to pass along the `self.iteration` everytime? With initializing it just once for `self.update_plan` will we still be doing that? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@madlib.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org