{"push_id":2855117627,"size":1,"distinct_size":1,"ref":"refs/heads/fix-mergeappend-pathtoplan","head":"b09ed84b82bdae509d4405a5babf3cc742991cda","before":"bdbb11b8b0cdc254a92865d121446f4f2840ce93","commits":[{"sha":"b09ed84b82bdae509d4405a5babf3cc742991cda","author":{"name":"Heikki Linnakangas","email":"9304c20251d03f4d84fc732cc8196e9ef6638e64@pivotal.io"},"message":"Fix \"could not find pathkey item to sort\" error with MergeAppend plans.\n\nWhen building a Sort node to represent the ordering that is preserved\nby a Motion node, in make_motion(), the call to make_sort_from_pathkeys()\nwould sometimes fail with \"could not find pathkey item to sort\". This\nhappened when the ordering was over a UNION ALL operation. When building\nMotion nodes for MergeAppend subpaths, the path keys that represented the\nordering referred to the items in the append rel's target list, not the\nsubpaths. In create_merge_append_plan(), where we do a similar thing for\neach subpath, we correctly passed the 'relids' argument to\nprepare_sort_from_pathkeys(), so that prepare_sort_from_pathkeys() can\nmatch the target list entries of the append relation with the entries of\nthe subpaths. But when creating the Motion nodes for each subpath, we\nwere passing NULL as 'relids' (via make_sort_from_pathkeys()).\n\nAt a high level, the fix is straightforward: we need to pass the correct\n'relids' argument to prepare_sort_from_pathkeys(), in\ncdbpathtoplan_create_motion_plan(). However, the current code structure\nmakes that not so straightforward, so this required some refactoring of\nthe make_motion() and related functions:\n\nPreviously, make_motion() and make_sorted_union_motion() would take a path\nkey list as argument, to represent the ordering, and it called\nmake_sort_from_pathkeys() to extract the sort columns, operators etc.\nAfter this patch, those functions take arrays of sort columns, operators,\netc. directly as arguments, and the caller is expected to do the call to\nmake_sort_from_pathkeys() to get them, or build them through some other\nmeans. In cdbpathtoplan_create_motion_plan(), call\nprepare_sort_from_pathkeys() directly, rather than the\nmake_sort_from_pathkeys() wrapper, so that we can pass the 'relids'\nargument. Because prepare_sort_from_pathkeys() is marked as 'static', move\ncdbpathtoplan_create_motion_plan() from cdbpathtoplan.c to createplan.c,\nso that it can call it.\n\nAdd test case. It's a slightly reduced version of a query that we already\nhad in 'olap_group' test, but seems better to be explicit. Revert the\nchange in expected output of 'olap_group', made in commit 28087f4e18,\nwhich memorized the error in the expected output.\n\nFixes https://github.com/greenplum-db/gpdb/issues/5695.\n\nfixup","distinct":true,"url":"https://api.github.com/repos/hlinnaka/gpdb/commits/b09ed84b82bdae509d4405a5babf3cc742991cda"}]}
{"actor":{"display_login":"hlinnaka"}}