{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-madlib/pulls/comments/57366247","id":57366247,"diff_hunk":"@@ -118,140 +120,175 @@ def path(schema_madlib, source_table, output_table, partition_expr,\n         #   string produced by concatenating the symbols. The exact rows that\n         #   produce the match are identified by correlating the matched string\n         #   indices with another array containing row ids.\n-        #\n-        #   matched_partitions: For each partition (group), concatenate all symbols\n-        #       into a single string (sym_str). Keep corresponding ids in an array in the\n-        #       same order as the symbols. This is performed only for partitions\n-        #       that contain a match.\n-        #   build_multiple_matched_rows:\n-        #       q1: Split sym_str into an array containing the lengths of the\n-        #           strings between the matches.\n-        #       q2: Store lengths of matches into an array\n-        #       q3: Merge q1 and q2 and unnest the arrays (ensuring same length).\n-        #           Also right shift the matches array.\n-        #       q4: Compute the cumulative sum of the arrays.\n+\n+        # matched_partitions: For each partition, concatenate all symbols\n+        #       into a single string (sym_str). Keep corresponding ids in an\n+        #       array (match_to_row_id) in the same order as the symbols.\n+        #       This is performed only for partitions that contain a match.\n+        match_id_name = \"__madlib_path_match_id__\" if \"match_id\" in all_input_cols else \"match_id\"\n+        symbol_name = \"__madlib_path_symbol__\" if \"symbol\" in all_input_cols else \"symbol\"\n         plpy.execute(\"\"\"\n             CREATE TEMP TABLE {matched_partitions} AS\n                 SELECT\n                     {p_col_name_str},\n-                    array_to_string(array_agg({symbol_name_str} ORDER BY {order_expr}), '') as sym_str,\n-                    array_agg({id_col_name} ORDER BY {order_expr}) as matched_ids\n+                    array_to_string(array_agg({short_sym_name_str} ORDER BY {order_expr}), '') as sym_str,\n+                    array_agg({id_col_name} ORDER BY {order_expr}) as {match_to_row_id}\n                 FROM {input_with_id}\n+                WHERE {short_sym_name_str} is NOT NULL\n                 GROUP BY {p_col_name_str}\n-                HAVING array_to_string(array_agg({symbol_name_str} ORDER BY {order_expr}), '') ~* '{pattern_expr}'\n+                HAVING array_to_string(array_agg({short_sym_name_str} ORDER BY {order_expr}), '')\n+                                ~* '{new_pattern_expr}'\n             \"\"\".format(**locals()))\n+\n+        # length_of_matches: For each partition in matched_partitions:\n+        #       - find all matches and compute the lengths of each match.\n+        #       - output these lengths in an array (matches), along with\n+        #         an array of corresponding rank of each match (match_indices).\n+        length_of_matches = unique_string(\"match_length_view\")\n+        plpy.execute(\"\"\"\n+            CREATE VIEW {length_of_matches} AS\n+            SELECT\n+                {p_col_name_str},\n+                {match_to_row_id},\n+                array_agg(length(matches) ORDER BY match_index) AS matches,\n+                array_agg(match_index ORDER BY match_index) AS match_indices\n+            FROM (\n+                SELECT\n+                    {p_col_name_str},\n+                    {match_to_row_id},","path":"src/ports/postgres/modules/utilities/path.py_in","position":136,"original_position":136,"commit_id":"867dd6adc8df0ba644b0e4f4c6575bd93b27366c","original_commit_id":"91a75682acab380c8705f3d34f55b04338fd7481","user":{"login":"mktal","id":4022529,"avatar_url":"https://avatars.githubusercontent.com/u/4022529?v=3","gravatar_id":"","url":"https://api.github.com/users/mktal","html_url":"https://github.com/mktal","followers_url":"https://api.github.com/users/mktal/followers","following_url":"https://api.github.com/users/mktal/following{/other_user}","gists_url":"https://api.github.com/users/mktal/gists{/gist_id}","starred_url":"https://api.github.com/users/mktal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mktal/subscriptions","organizations_url":"https://api.github.com/users/mktal/orgs","repos_url":"https://api.github.com/users/mktal/repos","events_url":"https://api.github.com/users/mktal/events{/privacy}","received_events_url":"https://api.github.com/users/mktal/received_events","type":"User","site_admin":false},"body":"Is it necessary to have {match_to_row_id} in both {length_of_matches} and {length_of_between_matches}?","created_at":"2016-03-24T18:35:09Z","updated_at":"2016-03-24T18:35:09Z","html_url":"https://github.com/apache/incubator-madlib/pull/29#discussion_r57366247","pull_request_url":"https://api.github.com/repos/apache/incubator-madlib/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-madlib/pulls/comments/57366247"},"html":{"href":"https://github.com/apache/incubator-madlib/pull/29#discussion_r57366247"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-madlib/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-madlib/pulls/29","id":62485199,"html_url":"https://github.com/apache/incubator-madlib/pull/29","diff_url":"https://github.com/apache/incubator-madlib/pull/29.diff","patch_url":"https://github.com/apache/incubator-madlib/pull/29.patch","issue_url":"https://api.github.com/repos/apache/incubator-madlib/issues/29","number":29,"state":"open","locked":false,"title":"Path: Return results for each match","user":{"login":"iyerr3","id":2237447,"avatar_url":"https://avatars.githubusercontent.com/u/2237447?v=3","gravatar_id":"","url":"https://api.github.com/users/iyerr3","html_url":"https://github.com/iyerr3","followers_url":"https://api.github.com/users/iyerr3/followers","following_url":"https://api.github.com/users/iyerr3/following{/other_user}","gists_url":"https://api.github.com/users/iyerr3/gists{/gist_id}","starred_url":"https://api.github.com/users/iyerr3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iyerr3/subscriptions","organizations_url":"https://api.github.com/users/iyerr3/orgs","repos_url":"https://api.github.com/users/iyerr3/repos","events_url":"https://api.github.com/users/iyerr3/events{/privacy}","received_events_url":"https://api.github.com/users/iyerr3/received_events","type":"User","site_admin":false},"body":"JIRA: MADLIB-973\r\n\r\n- Previously path returned the result per partition. This work changes\r\n  that to result per match within each partition.\r\n- 'agg_func' converted to a default argument.\r\n- Match ID and symbol string added to the output tuples table.","created_at":"2016-03-11T01:31:14Z","updated_at":"2016-03-24T18:35:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da5661493613b02f1fc7a41a4bf7790abbba434c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-madlib/pulls/29/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-madlib/pulls/29/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-madlib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-madlib/issues/29/comments","statuses_url":"https://api.github.com/repos/apache/incubator-madlib/statuses/867dd6adc8df0ba644b0e4f4c6575bd93b27366c","head":{"label":"iyerr3:feature/path_agg_per_match","ref":"feature/path_agg_per_match","sha":"867dd6adc8df0ba644b0e4f4c6575bd93b27366c","user":{"login":"iyerr3","id":2237447,"avatar_url":"https://avatars.githubusercontent.com/u/2237447?v=3","gravatar_id":"","url":"https://api.github.com/users/iyerr3","html_url":"https://github.com/iyerr3","followers_url":"https://api.github.com/users/iyerr3/followers","following_url":"https://api.github.com/users/iyerr3/following{/other_user}","gists_url":"https://api.github.com/users/iyerr3/gists{/gist_id}","starred_url":"https://api.github.com/users/iyerr3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iyerr3/subscriptions","organizations_url":"https://api.github.com/users/iyerr3/orgs","repos_url":"https://api.github.com/users/iyerr3/repos","events_url":"https://api.github.com/users/iyerr3/events{/privacy}","received_events_url":"https://api.github.com/users/iyerr3/received_events","type":"User","site_admin":false},"repo":{"id":45563801,"name":"incubator-madlib","full_name":"iyerr3/incubator-madlib","owner":{"login":"iyerr3","id":2237447,"avatar_url":"https://avatars.githubusercontent.com/u/2237447?v=3","gravatar_id":"","url":"https://api.github.com/users/iyerr3","html_url":"https://github.com/iyerr3","followers_url":"https://api.github.com/users/iyerr3/followers","following_url":"https://api.github.com/users/iyerr3/following{/other_user}","gists_url":"https://api.github.com/users/iyerr3/gists{/gist_id}","starred_url":"https://api.github.com/users/iyerr3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iyerr3/subscriptions","organizations_url":"https://api.github.com/users/iyerr3/orgs","repos_url":"https://api.github.com/users/iyerr3/repos","events_url":"https://api.github.com/users/iyerr3/events{/privacy}","received_events_url":"https://api.github.com/users/iyerr3/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iyerr3/incubator-madlib","description":"Mirror of Apache MADlib (Incubating)","fork":true,"url":"https://api.github.com/repos/iyerr3/incubator-madlib","forks_url":"https://api.github.com/repos/iyerr3/incubator-madlib/forks","keys_url":"https://api.github.com/repos/iyerr3/incubator-madlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iyerr3/incubator-madlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iyerr3/incubator-madlib/teams","hooks_url":"https://api.github.com/repos/iyerr3/incubator-madlib/hooks","issue_events_url":"https://api.github.com/repos/iyerr3/incubator-madlib/issues/events{/number}","events_url":"https://api.github.com/repos/iyerr3/incubator-madlib/events","assignees_url":"https://api.github.com/repos/iyerr3/incubator-madlib/assignees{/user}","branches_url":"https://api.github.com/repos/iyerr3/incubator-madlib/branches{/branch}","tags_url":"https://api.github.com/repos/iyerr3/incubator-madlib/tags","blobs_url":"https://api.github.com/repos/iyerr3/incubator-madlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iyerr3/incubator-madlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iyerr3/incubator-madlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/iyerr3/incubator-madlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iyerr3/incubator-madlib/statuses/{sha}","languages_url":"https://api.github.com/repos/iyerr3/incubator-madlib/languages","stargazers_url":"https://api.github.com/repos/iyerr3/incubator-madlib/stargazers","contributors_url":"https://api.github.com/repos/iyerr3/incubator-madlib/contributors","subscribers_url":"https://api.github.com/repos/iyerr3/incubator-madlib/subscribers","subscription_url":"https://api.github.com/repos/iyerr3/incubator-madlib/subscription","commits_url":"https://api.github.com/repos/iyerr3/incubator-madlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/iyerr3/incubator-madlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/iyerr3/incubator-madlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/iyerr3/incubator-madlib/issues/comments{/number}","contents_url":"https://api.github.com/repos/iyerr3/incubator-madlib/contents/{+path}","compare_url":"https://api.github.com/repos/iyerr3/incubator-madlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iyerr3/incubator-madlib/merges","archive_url":"https://api.github.com/repos/iyerr3/incubator-madlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iyerr3/incubator-madlib/downloads","issues_url":"https://api.github.com/repos/iyerr3/incubator-madlib/issues{/number}","pulls_url":"https://api.github.com/repos/iyerr3/incubator-madlib/pulls{/number}","milestones_url":"https://api.github.com/repos/iyerr3/incubator-madlib/milestones{/number}","notifications_url":"https://api.github.com/repos/iyerr3/incubator-madlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iyerr3/incubator-madlib/labels{/name}","releases_url":"https://api.github.com/repos/iyerr3/incubator-madlib/releases{/id}","deployments_url":"https://api.github.com/repos/iyerr3/incubator-madlib/deployments","created_at":"2015-11-04T19:57:14Z","updated_at":"2015-11-16T21:52:06Z","pushed_at":"2016-03-21T21:33:01Z","git_url":"git://github.com/iyerr3/incubator-madlib.git","ssh_url":"git@github.com:iyerr3/incubator-madlib.git","clone_url":"https://github.com/iyerr3/incubator-madlib.git","svn_url":"https://github.com/iyerr3/incubator-madlib","homepage":null,"size":15595,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"c9cb10cda6c42839d367ca635c8621d8a0b374a1","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":42763345,"name":"incubator-madlib","full_name":"apache/incubator-madlib","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-madlib","description":"Mirror of Apache MADlib (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-madlib","forks_url":"https://api.github.com/repos/apache/incubator-madlib/forks","keys_url":"https://api.github.com/repos/apache/incubator-madlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-madlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-madlib/teams","hooks_url":"https://api.github.com/repos/apache/incubator-madlib/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-madlib/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-madlib/events","assignees_url":"https://api.github.com/repos/apache/incubator-madlib/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-madlib/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-madlib/tags","blobs_url":"https://api.github.com/repos/apache/incubator-madlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-madlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-madlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-madlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-madlib/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-madlib/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-madlib/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-madlib/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-madlib/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-madlib/subscription","commits_url":"https://api.github.com/repos/apache/incubator-madlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-madlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-madlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-madlib/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-madlib/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-madlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-madlib/merges","archive_url":"https://api.github.com/repos/apache/incubator-madlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-madlib/downloads","issues_url":"https://api.github.com/repos/apache/incubator-madlib/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-madlib/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-madlib/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-madlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-madlib/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-madlib/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-madlib/deployments","created_at":"2015-09-19T07:00:06Z","updated_at":"2016-03-24T08:58:54Z","pushed_at":"2016-03-21T21:33:01Z","git_url":"git://github.com/apache/incubator-madlib.git","ssh_url":"git@github.com:apache/incubator-madlib.git","clone_url":"https://github.com/apache/incubator-madlib.git","svn_url":"https://github.com/apache/incubator-madlib","homepage":null,"size":15585,"stargazers_count":33,"watchers_count":33,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":26,"mirror_url":"git://git.apache.org/incubator-madlib.git","open_issues_count":5,"forks":26,"open_issues":5,"watchers":33,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-madlib/pulls/29"},"html":{"href":"https://github.com/apache/incubator-madlib/pull/29"},"issue":{"href":"https://api.github.com/repos/apache/incubator-madlib/issues/29"},"comments":{"href":"https://api.github.com/repos/apache/incubator-madlib/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-madlib/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-madlib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-madlib/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-madlib/statuses/867dd6adc8df0ba644b0e4f4c6575bd93b27366c"}}}}