{"action":"created","comment":{"url":"https://api.github.com/repos/linkedin/pinot/pulls/comments/66925418","id":66925418,"diff_hunk":"@@ -516,55 +516,57 @@ public static JSONArray getJSonArrayFromRow(Serializable[] poll, List<String> se\n   public static Serializable[] getFormattedRow(Serializable[] inputValues, List<String> selectionColumns,\n       DataSchema dataSchema)\n       throws JSONException {\n-    Serializable[] formattedRow = new Serializable[inputValues.length];\n-\n-    for (int i = 0; i < dataSchema.size(); ++i) {\n-      // If column not part of schema, we don't know how to format it, so just skip.\n-      if (!selectionColumns.contains(dataSchema.getColumnName(i))) {\n+    Serializable[] formattedRow = new Serializable[selectionColumns.size()];\n+\n+    for (int i = 0; i < selectionColumns.size(); ++i) {\n+      int idxInDataSchema = getColumnIdxInDataSchema(selectionColumns.get(i), dataSchema);","path":"pinot-core/src/main/java/com/linkedin/pinot/core/query/selection/SelectionOperatorUtils.java","position":12,"original_position":12,"commit_id":"2a8a15a4920b8e213ceba5d91e84db92cc83e88e","original_commit_id":"2a8a15a4920b8e213ceba5d91e84db92cc83e88e","user":{"login":"kishoreg","id":850791,"avatar_url":"https://avatars.githubusercontent.com/u/850791?v=3","gravatar_id":"","url":"https://api.github.com/users/kishoreg","html_url":"https://github.com/kishoreg","followers_url":"https://api.github.com/users/kishoreg/followers","following_url":"https://api.github.com/users/kishoreg/following{/other_user}","gists_url":"https://api.github.com/users/kishoreg/gists{/gist_id}","starred_url":"https://api.github.com/users/kishoreg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kishoreg/subscriptions","organizations_url":"https://api.github.com/users/kishoreg/orgs","repos_url":"https://api.github.com/users/kishoreg/repos","events_url":"https://api.github.com/users/kishoreg/events{/privacy}","received_events_url":"https://api.github.com/users/kishoreg/received_events","type":"User","site_admin":false},"body":"instead of doing this for every column, compute the columnName to index map once outside the loop","created_at":"2016-06-14T08:09:29Z","updated_at":"2016-06-14T08:09:29Z","html_url":"https://github.com/linkedin/pinot/pull/194#discussion_r66925418","pull_request_url":"https://api.github.com/repos/linkedin/pinot/pulls/194","_links":{"self":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/comments/66925418"},"html":{"href":"https://github.com/linkedin/pinot/pull/194#discussion_r66925418"},"pull_request":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/194"}}},"pull_request":{"url":"https://api.github.com/repos/linkedin/pinot/pulls/194","id":73696046,"html_url":"https://github.com/linkedin/pinot/pull/194","diff_url":"https://github.com/linkedin/pinot/pull/194.diff","patch_url":"https://github.com/linkedin/pinot/pull/194.patch","issue_url":"https://api.github.com/repos/linkedin/pinot/issues/194","number":194,"state":"open","locked":false,"title":"Bugfixing: wrong query results if order by columns not existed in select columns list","user":{"login":"fx19880617","id":1202120,"avatar_url":"https://avatars.githubusercontent.com/u/1202120?v=3","gravatar_id":"","url":"https://api.github.com/users/fx19880617","html_url":"https://github.com/fx19880617","followers_url":"https://api.github.com/users/fx19880617/followers","following_url":"https://api.github.com/users/fx19880617/following{/other_user}","gists_url":"https://api.github.com/users/fx19880617/gists{/gist_id}","starred_url":"https://api.github.com/users/fx19880617/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fx19880617/subscriptions","organizations_url":"https://api.github.com/users/fx19880617/orgs","repos_url":"https://api.github.com/users/fx19880617/repos","events_url":"https://api.github.com/users/fx19880617/events{/privacy}","received_events_url":"https://api.github.com/users/fx19880617/received_events","type":"User","site_admin":false},"body":"Right now query : select city_id from hive-api-created_trips order by SecondsSinceEpoch limit 2\r\nwill give wrong results:\r\n{\r\n    \"selectionResults\": {\r\n        \"columns\": [\"city_id\"],\r\n        \"results\": [\r\n            [null, \"484\"],\r\n            [null, \"195\"]\r\n        ]\r\n    },\r\n....\r\n}\r\nThe reason is during render the results, we pre-assume the query result will have all the columns from data schema which is combined sorting columns and selected columns.\r\n\r\nTo fix this, we should use the number of selection columns to make the array size and fill in the values.\r\n\r\nRight now, if we select columns not existed in a segment, then the entire segment will return null as response, so in the render steps, all the select columns must be in the data schema.\r\n\r\n","created_at":"2016-06-14T08:04:27Z","updated_at":"2016-06-14T08:09:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0f67c9efdc9181fc77577c5c31e5a4bb14d8d5de","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/linkedin/pinot/pulls/194/commits","review_comments_url":"https://api.github.com/repos/linkedin/pinot/pulls/194/comments","review_comment_url":"https://api.github.com/repos/linkedin/pinot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linkedin/pinot/issues/194/comments","statuses_url":"https://api.github.com/repos/linkedin/pinot/statuses/2a8a15a4920b8e213ceba5d91e84db92cc83e88e","head":{"label":"linkedin:bugfixing_select_order_by_wrong_results","ref":"bugfixing_select_order_by_wrong_results","sha":"2a8a15a4920b8e213ceba5d91e84db92cc83e88e","user":{"login":"linkedin","id":357098,"avatar_url":"https://avatars.githubusercontent.com/u/357098?v=3","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"repo":{"id":19961085,"name":"pinot","full_name":"linkedin/pinot","owner":{"login":"linkedin","id":357098,"avatar_url":"https://avatars.githubusercontent.com/u/357098?v=3","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linkedin/pinot","description":"A realtime distributed OLAP datastore","fork":false,"url":"https://api.github.com/repos/linkedin/pinot","forks_url":"https://api.github.com/repos/linkedin/pinot/forks","keys_url":"https://api.github.com/repos/linkedin/pinot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linkedin/pinot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linkedin/pinot/teams","hooks_url":"https://api.github.com/repos/linkedin/pinot/hooks","issue_events_url":"https://api.github.com/repos/linkedin/pinot/issues/events{/number}","events_url":"https://api.github.com/repos/linkedin/pinot/events","assignees_url":"https://api.github.com/repos/linkedin/pinot/assignees{/user}","branches_url":"https://api.github.com/repos/linkedin/pinot/branches{/branch}","tags_url":"https://api.github.com/repos/linkedin/pinot/tags","blobs_url":"https://api.github.com/repos/linkedin/pinot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linkedin/pinot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linkedin/pinot/git/refs{/sha}","trees_url":"https://api.github.com/repos/linkedin/pinot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linkedin/pinot/statuses/{sha}","languages_url":"https://api.github.com/repos/linkedin/pinot/languages","stargazers_url":"https://api.github.com/repos/linkedin/pinot/stargazers","contributors_url":"https://api.github.com/repos/linkedin/pinot/contributors","subscribers_url":"https://api.github.com/repos/linkedin/pinot/subscribers","subscription_url":"https://api.github.com/repos/linkedin/pinot/subscription","commits_url":"https://api.github.com/repos/linkedin/pinot/commits{/sha}","git_commits_url":"https://api.github.com/repos/linkedin/pinot/git/commits{/sha}","comments_url":"https://api.github.com/repos/linkedin/pinot/comments{/number}","issue_comment_url":"https://api.github.com/repos/linkedin/pinot/issues/comments{/number}","contents_url":"https://api.github.com/repos/linkedin/pinot/contents/{+path}","compare_url":"https://api.github.com/repos/linkedin/pinot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linkedin/pinot/merges","archive_url":"https://api.github.com/repos/linkedin/pinot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linkedin/pinot/downloads","issues_url":"https://api.github.com/repos/linkedin/pinot/issues{/number}","pulls_url":"https://api.github.com/repos/linkedin/pinot/pulls{/number}","milestones_url":"https://api.github.com/repos/linkedin/pinot/milestones{/number}","notifications_url":"https://api.github.com/repos/linkedin/pinot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linkedin/pinot/labels{/name}","releases_url":"https://api.github.com/repos/linkedin/pinot/releases{/id}","deployments_url":"https://api.github.com/repos/linkedin/pinot/deployments","created_at":"2014-05-19T23:27:48Z","updated_at":"2016-06-14T04:53:52Z","pushed_at":"2016-06-14T08:04:28Z","git_url":"git://github.com/linkedin/pinot.git","ssh_url":"git@github.com:linkedin/pinot.git","clone_url":"https://github.com/linkedin/pinot.git","svn_url":"https://github.com/linkedin/pinot","homepage":"https://github.com/linkedin/pinot/wiki","size":130630,"stargazers_count":1265,"watchers_count":1265,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":204,"mirror_url":null,"open_issues_count":69,"forks":204,"open_issues":69,"watchers":1265,"default_branch":"master"}},"base":{"label":"linkedin:master","ref":"master","sha":"12c9a156529c24d8581609b311bf62a098150959","user":{"login":"linkedin","id":357098,"avatar_url":"https://avatars.githubusercontent.com/u/357098?v=3","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"repo":{"id":19961085,"name":"pinot","full_name":"linkedin/pinot","owner":{"login":"linkedin","id":357098,"avatar_url":"https://avatars.githubusercontent.com/u/357098?v=3","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linkedin/pinot","description":"A realtime distributed OLAP datastore","fork":false,"url":"https://api.github.com/repos/linkedin/pinot","forks_url":"https://api.github.com/repos/linkedin/pinot/forks","keys_url":"https://api.github.com/repos/linkedin/pinot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linkedin/pinot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linkedin/pinot/teams","hooks_url":"https://api.github.com/repos/linkedin/pinot/hooks","issue_events_url":"https://api.github.com/repos/linkedin/pinot/issues/events{/number}","events_url":"https://api.github.com/repos/linkedin/pinot/events","assignees_url":"https://api.github.com/repos/linkedin/pinot/assignees{/user}","branches_url":"https://api.github.com/repos/linkedin/pinot/branches{/branch}","tags_url":"https://api.github.com/repos/linkedin/pinot/tags","blobs_url":"https://api.github.com/repos/linkedin/pinot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linkedin/pinot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linkedin/pinot/git/refs{/sha}","trees_url":"https://api.github.com/repos/linkedin/pinot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linkedin/pinot/statuses/{sha}","languages_url":"https://api.github.com/repos/linkedin/pinot/languages","stargazers_url":"https://api.github.com/repos/linkedin/pinot/stargazers","contributors_url":"https://api.github.com/repos/linkedin/pinot/contributors","subscribers_url":"https://api.github.com/repos/linkedin/pinot/subscribers","subscription_url":"https://api.github.com/repos/linkedin/pinot/subscription","commits_url":"https://api.github.com/repos/linkedin/pinot/commits{/sha}","git_commits_url":"https://api.github.com/repos/linkedin/pinot/git/commits{/sha}","comments_url":"https://api.github.com/repos/linkedin/pinot/comments{/number}","issue_comment_url":"https://api.github.com/repos/linkedin/pinot/issues/comments{/number}","contents_url":"https://api.github.com/repos/linkedin/pinot/contents/{+path}","compare_url":"https://api.github.com/repos/linkedin/pinot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linkedin/pinot/merges","archive_url":"https://api.github.com/repos/linkedin/pinot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linkedin/pinot/downloads","issues_url":"https://api.github.com/repos/linkedin/pinot/issues{/number}","pulls_url":"https://api.github.com/repos/linkedin/pinot/pulls{/number}","milestones_url":"https://api.github.com/repos/linkedin/pinot/milestones{/number}","notifications_url":"https://api.github.com/repos/linkedin/pinot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linkedin/pinot/labels{/name}","releases_url":"https://api.github.com/repos/linkedin/pinot/releases{/id}","deployments_url":"https://api.github.com/repos/linkedin/pinot/deployments","created_at":"2014-05-19T23:27:48Z","updated_at":"2016-06-14T04:53:52Z","pushed_at":"2016-06-14T08:04:28Z","git_url":"git://github.com/linkedin/pinot.git","ssh_url":"git@github.com:linkedin/pinot.git","clone_url":"https://github.com/linkedin/pinot.git","svn_url":"https://github.com/linkedin/pinot","homepage":"https://github.com/linkedin/pinot/wiki","size":130630,"stargazers_count":1265,"watchers_count":1265,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":204,"mirror_url":null,"open_issues_count":69,"forks":204,"open_issues":69,"watchers":1265,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/194"},"html":{"href":"https://github.com/linkedin/pinot/pull/194"},"issue":{"href":"https://api.github.com/repos/linkedin/pinot/issues/194"},"comments":{"href":"https://api.github.com/repos/linkedin/pinot/issues/194/comments"},"review_comments":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/194/comments"},"review_comment":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linkedin/pinot/pulls/194/commits"},"statuses":{"href":"https://api.github.com/repos/linkedin/pinot/statuses/2a8a15a4920b8e213ceba5d91e84db92cc83e88e"}}}}
{"actor":{"display_login":"kishoreg"}}