{"action":"created","comment":{"url":"https://api.github.com/repos/m3db/m3coordinator/pulls/comments/180226184","pull_request_review_id":110611822,"id":180226184,"diff_hunk":"@@ -0,0 +1,85 @@\n+package promql\n+\n+import (\n+\t\"fmt\"\n+\n+\t\"github.com/m3db/m3coordinator/parser\"\n+\tpql \"github.com/prometheus/prometheus/promql\"\n+)\n+\n+type promParser struct {\n+\texpr pql.Expr\n+}\n+\n+// Parse takes a promQL string and converts parses it into a DAG\n+func Parse(q string) (parser.Parser, error) {\n+\texpr, err := pql.ParseExpr(q)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\treturn &promParser{expr: expr}, nil\n+\n+}\n+\n+func (p *promParser) DAG() (parser.Transforms, parser.Edges, error) {\n+\treturn walk(p.expr)\n+}\n+\n+func (p *promParser) String() string {\n+\treturn p.expr.String()\n+}\n+\n+func walk(node pql.Node) (parser.Transforms, parser.Edges, error) {\n+\tif node == nil {\n+\t\treturn nil, nil, nil\n+\t}\n+\n+\tswitch n := node.(type) {\n+\tcase pql.Statements:\n+\tcase *pql.AlertStmt:\n+\n+\tcase *pql.EvalStmt:\n+\n+\tcase *pql.RecordStmt:\n+\n+\tcase pql.Expressions:\n+\tcase *pql.AggregateExpr:\n+\t\ttransforms, edges, err := walk(n.Expr)\n+\t\tif err != nil {\n+\t\t\treturn nil, nil, err\n+\t\t}\n+\n+\t\topTransform := parser.NewTransformFromOperation(NewOperator(n.Op), len(transforms))\n+\t\tedges = append(edges, &parser.Edge{\n+\t\t\tParentID: transforms[len(transforms)-1].ID,\n+\t\t\tChildID:  opTransform.ID,\n+\t\t})\n+\t\ttransforms = append(transforms, opTransform)","path":"parser/promql/parse.go","position":57,"original_position":58,"commit_id":"ada9336d14e9d5ee6be52f3e2b260772b0dc514e","original_commit_id":"f47481b2a4eb5312cc5963ba9ebb5e7ec11cd5b6","user":{"login":"arnikola","id":14959893,"avatar_url":"https://avatars0.githubusercontent.com/u/14959893?v=4","gravatar_id":"","url":"https://api.github.com/users/arnikola","html_url":"https://github.com/arnikola","followers_url":"https://api.github.com/users/arnikola/followers","following_url":"https://api.github.com/users/arnikola/following{/other_user}","gists_url":"https://api.github.com/users/arnikola/gists{/gist_id}","starred_url":"https://api.github.com/users/arnikola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnikola/subscriptions","organizations_url":"https://api.github.com/users/arnikola/orgs","repos_url":"https://api.github.com/users/arnikola/repos","events_url":"https://api.github.com/users/arnikola/events{/privacy}","received_events_url":"https://api.github.com/users/arnikola/received_events","type":"User","site_admin":false},"body":"Are there multiple parsers per query? I thought you'd have one parser per request (or maybe per pipeline?)","created_at":"2018-04-09T20:50:19Z","updated_at":"2018-04-09T20:50:19Z","html_url":"https://github.com/m3db/m3coordinator/pull/35#discussion_r180226184","pull_request_url":"https://api.github.com/repos/m3db/m3coordinator/pulls/35","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/m3db/m3coordinator/pulls/comments/180226184"},"html":{"href":"https://github.com/m3db/m3coordinator/pull/35#discussion_r180226184"},"pull_request":{"href":"https://api.github.com/repos/m3db/m3coordinator/pulls/35"}},"in_reply_to_id":180200197},"pull_request":{"url":"https://api.github.com/repos/m3db/m3coordinator/pulls/35","id":179824301,"html_url":"https://github.com/m3db/m3coordinator/pull/35","diff_url":"https://github.com/m3db/m3coordinator/pull/35.diff","patch_url":"https://github.com/m3db/m3coordinator/pull/35.patch","issue_url":"https://api.github.com/repos/m3db/m3coordinator/issues/35","number":35,"state":"open","locked":false,"title":"Add prom parser","user":{"login":"nikunjgit","id":1733496,"avatar_url":"https://avatars3.githubusercontent.com/u/1733496?v=4","gravatar_id":"","url":"https://api.github.com/users/nikunjgit","html_url":"https://github.com/nikunjgit","followers_url":"https://api.github.com/users/nikunjgit/followers","following_url":"https://api.github.com/users/nikunjgit/following{/other_user}","gists_url":"https://api.github.com/users/nikunjgit/gists{/gist_id}","starred_url":"https://api.github.com/users/nikunjgit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikunjgit/subscriptions","organizations_url":"https://api.github.com/users/nikunjgit/orgs","repos_url":"https://api.github.com/users/nikunjgit/repos","events_url":"https://api.github.com/users/nikunjgit/events{/privacy}","received_events_url":"https://api.github.com/users/nikunjgit/received_events","type":"User","site_admin":false},"body":"Basic interfaces for parsing and DAG generation","created_at":"2018-04-05T23:43:55Z","updated_at":"2018-04-09T20:50:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"74d2a13f590d63dedce669c4e8510fc476aa556d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"benraskin92","id":4688976,"avatar_url":"https://avatars0.githubusercontent.com/u/4688976?v=4","gravatar_id":"","url":"https://api.github.com/users/benraskin92","html_url":"https://github.com/benraskin92","followers_url":"https://api.github.com/users/benraskin92/followers","following_url":"https://api.github.com/users/benraskin92/following{/other_user}","gists_url":"https://api.github.com/users/benraskin92/gists{/gist_id}","starred_url":"https://api.github.com/users/benraskin92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benraskin92/subscriptions","organizations_url":"https://api.github.com/users/benraskin92/orgs","repos_url":"https://api.github.com/users/benraskin92/repos","events_url":"https://api.github.com/users/benraskin92/events{/privacy}","received_events_url":"https://api.github.com/users/benraskin92/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/m3db/m3coordinator/pulls/35/commits","review_comments_url":"https://api.github.com/repos/m3db/m3coordinator/pulls/35/comments","review_comment_url":"https://api.github.com/repos/m3db/m3coordinator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/m3db/m3coordinator/issues/35/comments","statuses_url":"https://api.github.com/repos/m3db/m3coordinator/statuses/ada9336d14e9d5ee6be52f3e2b260772b0dc514e","head":{"label":"m3db:parsingProm","ref":"parsingProm","sha":"ada9336d14e9d5ee6be52f3e2b260772b0dc514e","user":{"login":"m3db","id":19937171,"avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"repo":{"id":110602995,"name":"m3coordinator","full_name":"m3db/m3coordinator","owner":{"login":"m3db","id":19937171,"avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m3db/m3coordinator","description":"Query and API server for single and multi-cluster M3DB deployments","fork":false,"url":"https://api.github.com/repos/m3db/m3coordinator","forks_url":"https://api.github.com/repos/m3db/m3coordinator/forks","keys_url":"https://api.github.com/repos/m3db/m3coordinator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m3db/m3coordinator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m3db/m3coordinator/teams","hooks_url":"https://api.github.com/repos/m3db/m3coordinator/hooks","issue_events_url":"https://api.github.com/repos/m3db/m3coordinator/issues/events{/number}","events_url":"https://api.github.com/repos/m3db/m3coordinator/events","assignees_url":"https://api.github.com/repos/m3db/m3coordinator/assignees{/user}","branches_url":"https://api.github.com/repos/m3db/m3coordinator/branches{/branch}","tags_url":"https://api.github.com/repos/m3db/m3coordinator/tags","blobs_url":"https://api.github.com/repos/m3db/m3coordinator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m3db/m3coordinator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m3db/m3coordinator/git/refs{/sha}","trees_url":"https://api.github.com/repos/m3db/m3coordinator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m3db/m3coordinator/statuses/{sha}","languages_url":"https://api.github.com/repos/m3db/m3coordinator/languages","stargazers_url":"https://api.github.com/repos/m3db/m3coordinator/stargazers","contributors_url":"https://api.github.com/repos/m3db/m3coordinator/contributors","subscribers_url":"https://api.github.com/repos/m3db/m3coordinator/subscribers","subscription_url":"https://api.github.com/repos/m3db/m3coordinator/subscription","commits_url":"https://api.github.com/repos/m3db/m3coordinator/commits{/sha}","git_commits_url":"https://api.github.com/repos/m3db/m3coordinator/git/commits{/sha}","comments_url":"https://api.github.com/repos/m3db/m3coordinator/comments{/number}","issue_comment_url":"https://api.github.com/repos/m3db/m3coordinator/issues/comments{/number}","contents_url":"https://api.github.com/repos/m3db/m3coordinator/contents/{+path}","compare_url":"https://api.github.com/repos/m3db/m3coordinator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m3db/m3coordinator/merges","archive_url":"https://api.github.com/repos/m3db/m3coordinator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m3db/m3coordinator/downloads","issues_url":"https://api.github.com/repos/m3db/m3coordinator/issues{/number}","pulls_url":"https://api.github.com/repos/m3db/m3coordinator/pulls{/number}","milestones_url":"https://api.github.com/repos/m3db/m3coordinator/milestones{/number}","notifications_url":"https://api.github.com/repos/m3db/m3coordinator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m3db/m3coordinator/labels{/name}","releases_url":"https://api.github.com/repos/m3db/m3coordinator/releases{/id}","deployments_url":"https://api.github.com/repos/m3db/m3coordinator/deployments","created_at":"2017-11-13T21:14:11Z","updated_at":"2018-04-02T13:16:01Z","pushed_at":"2018-04-09T20:45:29Z","git_url":"git://github.com/m3db/m3coordinator.git","ssh_url":"git@github.com:m3db/m3coordinator.git","clone_url":"https://github.com/m3db/m3coordinator.git","svn_url":"https://github.com/m3db/m3coordinator","homepage":"","size":7082,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"m3db:master","ref":"master","sha":"4a6f062ab66d078cf1851f70b4208ad6c815ca75","user":{"login":"m3db","id":19937171,"avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"repo":{"id":110602995,"name":"m3coordinator","full_name":"m3db/m3coordinator","owner":{"login":"m3db","id":19937171,"avatar_url":"https://avatars0.githubusercontent.com/u/19937171?v=4","gravatar_id":"","url":"https://api.github.com/users/m3db","html_url":"https://github.com/m3db","followers_url":"https://api.github.com/users/m3db/followers","following_url":"https://api.github.com/users/m3db/following{/other_user}","gists_url":"https://api.github.com/users/m3db/gists{/gist_id}","starred_url":"https://api.github.com/users/m3db/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m3db/subscriptions","organizations_url":"https://api.github.com/users/m3db/orgs","repos_url":"https://api.github.com/users/m3db/repos","events_url":"https://api.github.com/users/m3db/events{/privacy}","received_events_url":"https://api.github.com/users/m3db/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/m3db/m3coordinator","description":"Query and API server for single and multi-cluster M3DB deployments","fork":false,"url":"https://api.github.com/repos/m3db/m3coordinator","forks_url":"https://api.github.com/repos/m3db/m3coordinator/forks","keys_url":"https://api.github.com/repos/m3db/m3coordinator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/m3db/m3coordinator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/m3db/m3coordinator/teams","hooks_url":"https://api.github.com/repos/m3db/m3coordinator/hooks","issue_events_url":"https://api.github.com/repos/m3db/m3coordinator/issues/events{/number}","events_url":"https://api.github.com/repos/m3db/m3coordinator/events","assignees_url":"https://api.github.com/repos/m3db/m3coordinator/assignees{/user}","branches_url":"https://api.github.com/repos/m3db/m3coordinator/branches{/branch}","tags_url":"https://api.github.com/repos/m3db/m3coordinator/tags","blobs_url":"https://api.github.com/repos/m3db/m3coordinator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/m3db/m3coordinator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/m3db/m3coordinator/git/refs{/sha}","trees_url":"https://api.github.com/repos/m3db/m3coordinator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/m3db/m3coordinator/statuses/{sha}","languages_url":"https://api.github.com/repos/m3db/m3coordinator/languages","stargazers_url":"https://api.github.com/repos/m3db/m3coordinator/stargazers","contributors_url":"https://api.github.com/repos/m3db/m3coordinator/contributors","subscribers_url":"https://api.github.com/repos/m3db/m3coordinator/subscribers","subscription_url":"https://api.github.com/repos/m3db/m3coordinator/subscription","commits_url":"https://api.github.com/repos/m3db/m3coordinator/commits{/sha}","git_commits_url":"https://api.github.com/repos/m3db/m3coordinator/git/commits{/sha}","comments_url":"https://api.github.com/repos/m3db/m3coordinator/comments{/number}","issue_comment_url":"https://api.github.com/repos/m3db/m3coordinator/issues/comments{/number}","contents_url":"https://api.github.com/repos/m3db/m3coordinator/contents/{+path}","compare_url":"https://api.github.com/repos/m3db/m3coordinator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/m3db/m3coordinator/merges","archive_url":"https://api.github.com/repos/m3db/m3coordinator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/m3db/m3coordinator/downloads","issues_url":"https://api.github.com/repos/m3db/m3coordinator/issues{/number}","pulls_url":"https://api.github.com/repos/m3db/m3coordinator/pulls{/number}","milestones_url":"https://api.github.com/repos/m3db/m3coordinator/milestones{/number}","notifications_url":"https://api.github.com/repos/m3db/m3coordinator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/m3db/m3coordinator/labels{/name}","releases_url":"https://api.github.com/repos/m3db/m3coordinator/releases{/id}","deployments_url":"https://api.github.com/repos/m3db/m3coordinator/deployments","created_at":"2017-11-13T21:14:11Z","updated_at":"2018-04-02T13:16:01Z","pushed_at":"2018-04-09T20:45:29Z","git_url":"git://github.com/m3db/m3coordinator.git","ssh_url":"git@github.com:m3db/m3coordinator.git","clone_url":"https://github.com/m3db/m3coordinator.git","svn_url":"https://github.com/m3db/m3coordinator","homepage":"","size":7082,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/m3db/m3coordinator/pulls/35"},"html":{"href":"https://github.com/m3db/m3coordinator/pull/35"},"issue":{"href":"https://api.github.com/repos/m3db/m3coordinator/issues/35"},"comments":{"href":"https://api.github.com/repos/m3db/m3coordinator/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/m3db/m3coordinator/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/m3db/m3coordinator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/m3db/m3coordinator/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/m3db/m3coordinator/statuses/ada9336d14e9d5ee6be52f3e2b260772b0dc514e"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"arnikola"}}