* Parallel processing of window functions. * * NB: it may produce non-deterministic results if the window function * lacks ORDER BY and PARTITION BY clause. * SQL:2011 has clarified this behavior. */
| 9146 | * SQL:2011 has clarified this behavior. |
| 9147 | */ |
| 9148 | static void |
| 9149 | create_partial_window_path(PlannerInfo *root, |
| 9150 | RelOptInfo *window_rel, |
| 9151 | Path *path, |
| 9152 | PathTarget *input_target, |
| 9153 | PathTarget *output_target, |
| 9154 | WindowFuncLists *wflists, |
| 9155 | List *activeWindows) |
| 9156 | { |
| 9157 | PathTarget *window_target; |
| 9158 | ListCell *l; |
| 9159 | |
| 9160 | window_target = input_target; |
| 9161 | |
| 9162 | foreach(l, activeWindows) |
| 9163 | { |
| 9164 | WindowClause *wc = lfirst_node(WindowClause, l); |
| 9165 | List *window_pathkeys; |
| 9166 | int presorted_keys; |
| 9167 | bool is_sorted; |
| 9168 | |
| 9169 | window_pathkeys = make_pathkeys_for_window(root, |
| 9170 | wc, |
| 9171 | root->processed_tlist); |
| 9172 | |
| 9173 | is_sorted = pathkeys_count_contained_in(window_pathkeys, |
| 9174 | path->pathkeys, |
| 9175 | &presorted_keys); |
| 9176 | |
| 9177 | path = cdb_prepare_path_for_sorted_agg(root, |
| 9178 | is_sorted, |
| 9179 | presorted_keys, |
| 9180 | window_rel, |
| 9181 | path, |
| 9182 | path->pathtarget, |
| 9183 | window_pathkeys, |
| 9184 | -1.0, |
| 9185 | wc->partitionClause, |
| 9186 | NIL); |
| 9187 | if (lnext(activeWindows, l)) |
| 9188 | { |
| 9189 | ListCell *lc2; |
| 9190 | |
| 9191 | window_target = copy_pathtarget(window_target); |
| 9192 | foreach(lc2, wflists->windowFuncs[wc->winref]) |
| 9193 | { |
| 9194 | WindowFunc *wfunc = lfirst_node(WindowFunc, lc2); |
| 9195 | |
| 9196 | add_column_to_pathtarget(window_target, (Expr *) wfunc, 0); |
| 9197 | window_target->width += get_typavgwidth(wfunc->wintype, -1); |
| 9198 | } |
| 9199 | } |
| 9200 | else |
| 9201 | { |
| 9202 | window_target = output_target; |
| 9203 | } |
| 9204 | |
| 9205 | path = (Path *) |
no test coverage detected