{"action":"created","comment":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/221719462","pull_request_review_id":160438009,"id":221719462,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTcxOTQ2Mg==","diff_hunk":"@@ -71,6 +76,95 @@ type virtualSchemaTable struct {\n \tdelegate func(ctx context.Context, p *planner, db *DatabaseDescriptor) (planNode, error)\n }\n \n+// virtualSchemaView represents a view within a virtualSchema\n+type virtualSchemaView struct {\n+\tschema string\n+\n+\t// parent represents the table that the virtualSchemaView is augmenting\n+\tparent string\n+\n+\t// extraCols represents the resultColumns that the view appends to the parent's resultColumns\n+\textraCols sqlbase.ResultColumns\n+}\n+\n+func (t virtualSchemaTable) getSchema() string {\n+\treturn t.schema\n+}\n+\n+func (t virtualSchemaView) getSchema() string {\n+\treturn t.schema\n+}\n+\n+func (t virtualSchemaTable) initVirtualTableDesc(\n+\tctx context.Context, st *cluster.Settings,\n+) (sqlbase.TableDescriptor, error) {\n+\tstmt, err := parser.ParseOne(t.schema)\n+\tif err != nil {\n+\t\treturn sqlbase.TableDescriptor{}, err\n+\t}\n+\n+\tcreate := stmt.(*tree.CreateTable)\n+\tfor _, def := range create.Defs {\n+\t\tif d, ok := def.(*tree.ColumnTableDef); ok && d.HasDefaultExpr() {\n+\t\t\treturn sqlbase.TableDescriptor{},\n+\t\t\t\terrors.Errorf(\"virtual tables are not allowed to use default exprs \"+\n+\t\t\t\t\t\"because bootstrapping: %s:%s\", create.Table, d.Name)\n+\t\t}\n+\t}\n+\n+\t// Virtual tables never use SERIAL so we need not process SERIAL\n+\t// types here.\n+\treturn MakeTableDesc(\n+\t\tctx,\n+\t\tnil, /* txn */\n+\t\tnil, /* vt */\n+\t\tst,\n+\t\tcreate,\n+\t\t0, /* parentID */\n+\t\tkeys.VirtualDescriptorID,\n+\t\thlc.Timestamp{}, /* creationTime */\n+\t\tpublicSelectPrivileges,\n+\t\tnil, /* affected */\n+\t\tnil, /* semaCtx */\n+\t\tnil, /* evalCtx */\n+\t)\n+}\n+\n+func (v virtualSchemaView) initVirtualTableDesc(\n+\tctx context.Context, st *cluster.Settings, parentDesc *sqlbase.TableDescriptor,\n+) (sqlbase.TableDescriptor, error) {\n+\tstmt, err := parser.ParseOne(v.schema)\n+\tif err != nil {\n+\t\treturn sqlbase.TableDescriptor{}, err\n+\t}\n+\n+\tcreate := stmt.(*tree.CreateView)\n+\n+\treturn MakeViewTableDesc(\n+\t\tcreate,\n+\t\tv.getResultColumns(parentDesc),\n+\t\tkeys.DescriptorTableID,","path":"pkg/sql/virtual_schema.go","position":90,"original_position":90,"commit_id":"38de9d79465d5844bd6802b89746ba31a5ba061d","original_commit_id":"38de9d79465d5844bd6802b89746ba31a5ba061d","user":{"login":"changangela","id":19381001,"node_id":"MDQ6VXNlcjE5MzgxMDAx","avatar_url":"https://avatars3.githubusercontent.com/u/19381001?v=4","gravatar_id":"","url":"https://api.github.com/users/changangela","html_url":"https://github.com/changangela","followers_url":"https://api.github.com/users/changangela/followers","following_url":"https://api.github.com/users/changangela/following{/other_user}","gists_url":"https://api.github.com/users/changangela/gists{/gist_id}","starred_url":"https://api.github.com/users/changangela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/changangela/subscriptions","organizations_url":"https://api.github.com/users/changangela/orgs","repos_url":"https://api.github.com/users/changangela/repos","events_url":"https://api.github.com/users/changangela/events{/privacy}","received_events_url":"https://api.github.com/users/changangela/received_events","type":"User","site_admin":false},"body":"For some reason, using `0` as `parentID` and `keys.VirtualDescriptorID` as `ID` causes logictest to fail on the query `SELECT * FROM crdb_internal.ranges` (but this query works when using `./cockroach sql`).","created_at":"2018-10-01T18:57:56Z","updated_at":"2018-10-01T18:57:56Z","html_url":"https://github.com/cockroachdb/cockroach/pull/30846#discussion_r221719462","pull_request_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/30846","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments/221719462"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/30846#discussion_r221719462"},"pull_request":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/30846"}}},"pull_request":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/30846","id":219479166,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE5NDc5MTY2","html_url":"https://github.com/cockroachdb/cockroach/pull/30846","diff_url":"https://github.com/cockroachdb/cockroach/pull/30846.diff","patch_url":"https://github.com/cockroachdb/cockroach/pull/30846.patch","issue_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/30846","number":30846,"state":"open","locked":false,"title":"sql: turn ranges table into a view","user":{"login":"changangela","id":19381001,"node_id":"MDQ6VXNlcjE5MzgxMDAx","avatar_url":"https://avatars3.githubusercontent.com/u/19381001?v=4","gravatar_id":"","url":"https://api.github.com/users/changangela","html_url":"https://github.com/changangela","followers_url":"https://api.github.com/users/changangela/followers","following_url":"https://api.github.com/users/changangela/following{/other_user}","gists_url":"https://api.github.com/users/changangela/gists{/gist_id}","starred_url":"https://api.github.com/users/changangela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/changangela/subscriptions","organizations_url":"https://api.github.com/users/changangela/orgs","repos_url":"https://api.github.com/users/changangela/repos","events_url":"https://api.github.com/users/changangela/events{/privacy}","received_events_url":"https://api.github.com/users/changangela/received_events","type":"User","site_admin":false},"body":"We want to build `crdb_internal.ranges` table as a view over\r\n`crdb_internal.ranges_no_leases` in order to leverage the existing opt rules in\r\npushing down filters before the expensive computation on the `leaseholder`\r\ncolumn.\r\n\r\nRelease note: None","created_at":"2018-10-01T18:55:26Z","updated_at":"2018-10-01T18:57:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6152711db0a74173b823ea14b8bebb27d1717ef3","assignee":null,"assignees":[],"requested_reviewers":[{"login":"jordanlewis","id":43821,"node_id":"MDQ6VXNlcjQzODIx","avatar_url":"https://avatars1.githubusercontent.com/u/43821?v=4","gravatar_id":"","url":"https://api.github.com/users/jordanlewis","html_url":"https://github.com/jordanlewis","followers_url":"https://api.github.com/users/jordanlewis/followers","following_url":"https://api.github.com/users/jordanlewis/following{/other_user}","gists_url":"https://api.github.com/users/jordanlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/jordanlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jordanlewis/subscriptions","organizations_url":"https://api.github.com/users/jordanlewis/orgs","repos_url":"https://api.github.com/users/jordanlewis/repos","events_url":"https://api.github.com/users/jordanlewis/events{/privacy}","received_events_url":"https://api.github.com/users/jordanlewis/received_events","type":"User","site_admin":false},{"login":"asubiotto","id":10560359,"node_id":"MDQ6VXNlcjEwNTYwMzU5","avatar_url":"https://avatars2.githubusercontent.com/u/10560359?v=4","gravatar_id":"","url":"https://api.github.com/users/asubiotto","html_url":"https://github.com/asubiotto","followers_url":"https://api.github.com/users/asubiotto/followers","following_url":"https://api.github.com/users/asubiotto/following{/other_user}","gists_url":"https://api.github.com/users/asubiotto/gists{/gist_id}","starred_url":"https://api.github.com/users/asubiotto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asubiotto/subscriptions","organizations_url":"https://api.github.com/users/asubiotto/orgs","repos_url":"https://api.github.com/users/asubiotto/repos","events_url":"https://api.github.com/users/asubiotto/events{/privacy}","received_events_url":"https://api.github.com/users/asubiotto/received_events","type":"User","site_admin":false}],"requested_teams":[{"name":"sql-execution-prs","id":2437984,"node_id":"MDQ6VGVhbTI0Mzc5ODQ=","slug":"sql-execution-prs","description":"Join this team for notifications about SQL execution PRs","privacy":"closed","url":"https://api.github.com/teams/2437984","members_url":"https://api.github.com/teams/2437984/members{/member}","repositories_url":"https://api.github.com/teams/2437984/repos","permission":"pull"},{"name":"sql-planning-prs","id":2437986,"node_id":"MDQ6VGVhbTI0Mzc5ODY=","slug":"sql-planning-prs","description":"Join this team for notifications about SQL planning PRs","privacy":"closed","url":"https://api.github.com/teams/2437986","members_url":"https://api.github.com/teams/2437986/members{/member}","repositories_url":"https://api.github.com/teams/2437986/repos","permission":"pull"}],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/30846/commits","review_comments_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/30846/comments","review_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/30846/comments","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/38de9d79465d5844bd6802b89746ba31a5ba061d","head":{"label":"changangela:sql-create-view-for-ranges","ref":"sql-create-view-for-ranges","sha":"38de9d79465d5844bd6802b89746ba31a5ba061d","user":{"login":"changangela","id":19381001,"node_id":"MDQ6VXNlcjE5MzgxMDAx","avatar_url":"https://avatars3.githubusercontent.com/u/19381001?v=4","gravatar_id":"","url":"https://api.github.com/users/changangela","html_url":"https://github.com/changangela","followers_url":"https://api.github.com/users/changangela/followers","following_url":"https://api.github.com/users/changangela/following{/other_user}","gists_url":"https://api.github.com/users/changangela/gists{/gist_id}","starred_url":"https://api.github.com/users/changangela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/changangela/subscriptions","organizations_url":"https://api.github.com/users/changangela/orgs","repos_url":"https://api.github.com/users/changangela/repos","events_url":"https://api.github.com/users/changangela/events{/privacy}","received_events_url":"https://api.github.com/users/changangela/received_events","type":"User","site_admin":false},"repo":{"id":147747958,"node_id":"MDEwOlJlcG9zaXRvcnkxNDc3NDc5NTg=","name":"cockroach","full_name":"changangela/cockroach","private":false,"owner":{"login":"changangela","id":19381001,"node_id":"MDQ6VXNlcjE5MzgxMDAx","avatar_url":"https://avatars3.githubusercontent.com/u/19381001?v=4","gravatar_id":"","url":"https://api.github.com/users/changangela","html_url":"https://github.com/changangela","followers_url":"https://api.github.com/users/changangela/followers","following_url":"https://api.github.com/users/changangela/following{/other_user}","gists_url":"https://api.github.com/users/changangela/gists{/gist_id}","starred_url":"https://api.github.com/users/changangela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/changangela/subscriptions","organizations_url":"https://api.github.com/users/changangela/orgs","repos_url":"https://api.github.com/users/changangela/repos","events_url":"https://api.github.com/users/changangela/events{/privacy}","received_events_url":"https://api.github.com/users/changangela/received_events","type":"User","site_admin":false},"html_url":"https://github.com/changangela/cockroach","description":"CockroachDB - the open source, cloud-native SQL database.","fork":true,"url":"https://api.github.com/repos/changangela/cockroach","forks_url":"https://api.github.com/repos/changangela/cockroach/forks","keys_url":"https://api.github.com/repos/changangela/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/changangela/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/changangela/cockroach/teams","hooks_url":"https://api.github.com/repos/changangela/cockroach/hooks","issue_events_url":"https://api.github.com/repos/changangela/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/changangela/cockroach/events","assignees_url":"https://api.github.com/repos/changangela/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/changangela/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/changangela/cockroach/tags","blobs_url":"https://api.github.com/repos/changangela/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/changangela/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/changangela/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/changangela/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/changangela/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/changangela/cockroach/languages","stargazers_url":"https://api.github.com/repos/changangela/cockroach/stargazers","contributors_url":"https://api.github.com/repos/changangela/cockroach/contributors","subscribers_url":"https://api.github.com/repos/changangela/cockroach/subscribers","subscription_url":"https://api.github.com/repos/changangela/cockroach/subscription","commits_url":"https://api.github.com/repos/changangela/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/changangela/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/changangela/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/changangela/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/changangela/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/changangela/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/changangela/cockroach/merges","archive_url":"https://api.github.com/repos/changangela/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/changangela/cockroach/downloads","issues_url":"https://api.github.com/repos/changangela/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/changangela/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/changangela/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/changangela/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/changangela/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/changangela/cockroach/releases{/id}","deployments_url":"https://api.github.com/repos/changangela/cockroach/deployments","created_at":"2018-09-07T00:14:44Z","updated_at":"2018-09-07T00:14:59Z","pushed_at":"2018-10-01T18:54:01Z","git_url":"git://github.com/changangela/cockroach.git","ssh_url":"git@github.com:changangela/cockroach.git","clone_url":"https://github.com/changangela/cockroach.git","svn_url":"https://github.com/changangela/cockroach","homepage":"https://www.cockroachlabs.com","size":549558,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cockroachdb:master","ref":"master","sha":"ed94538d8877472232b4063aaa8a03e32c6e183b","user":{"login":"cockroachdb","id":6748139,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3NDgxMzk=","avatar_url":"https://avatars3.githubusercontent.com/u/6748139?v=4","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"repo":{"id":16563587,"node_id":"MDEwOlJlcG9zaXRvcnkxNjU2MzU4Nw==","name":"cockroach","full_name":"cockroachdb/cockroach","private":false,"owner":{"login":"cockroachdb","id":6748139,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3NDgxMzk=","avatar_url":"https://avatars3.githubusercontent.com/u/6748139?v=4","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/cockroachdb/cockroach","description":"CockroachDB - the open source, cloud-native SQL database.","fork":false,"url":"https://api.github.com/repos/cockroachdb/cockroach","forks_url":"https://api.github.com/repos/cockroachdb/cockroach/forks","keys_url":"https://api.github.com/repos/cockroachdb/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockroachdb/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockroachdb/cockroach/teams","hooks_url":"https://api.github.com/repos/cockroachdb/cockroach/hooks","issue_events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/cockroachdb/cockroach/events","assignees_url":"https://api.github.com/repos/cockroachdb/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/cockroachdb/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/cockroachdb/cockroach/tags","blobs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockroachdb/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockroachdb/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/cockroachdb/cockroach/languages","stargazers_url":"https://api.github.com/repos/cockroachdb/cockroach/stargazers","contributors_url":"https://api.github.com/repos/cockroachdb/cockroach/contributors","subscribers_url":"https://api.github.com/repos/cockroachdb/cockroach/subscribers","subscription_url":"https://api.github.com/repos/cockroachdb/cockroach/subscription","commits_url":"https://api.github.com/repos/cockroachdb/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockroachdb/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockroachdb/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/cockroachdb/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockroachdb/cockroach/merges","archive_url":"https://api.github.com/repos/cockroachdb/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockroachdb/cockroach/downloads","issues_url":"https://api.github.com/repos/cockroachdb/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/cockroachdb/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/cockroachdb/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/cockroachdb/cockroach/releases{/id}","deployments_url":"https://api.github.com/repos/cockroachdb/cockroach/deployments","created_at":"2014-02-06T00:18:47Z","updated_at":"2018-10-01T16:36:59Z","pushed_at":"2018-10-01T18:56:12Z","git_url":"git://github.com/cockroachdb/cockroach.git","ssh_url":"git@github.com:cockroachdb/cockroach.git","clone_url":"https://github.com/cockroachdb/cockroach.git","svn_url":"https://github.com/cockroachdb/cockroach","homepage":"https://www.cockroachlabs.com","size":1039233,"stargazers_count":14384,"watchers_count":14384,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1515,"mirror_url":null,"archived":false,"open_issues_count":1931,"license":{"key":"other","name":"NOASSERTION","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1515,"open_issues":1931,"watchers":14384,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/30846"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/30846"},"issue":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/30846"},"comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/30846/comments"},"review_comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/30846/comments"},"review_comment":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/30846/commits"},"statuses":{"href":"https://api.github.com/repos/cockroachdb/cockroach/statuses/38de9d79465d5844bd6802b89746ba31a5ba061d"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"changangela"}}