{"action":"created","comment":{"url":"https://api.github.com/repos/yahoo/fili/pulls/comments/103329701","pull_request_review_id":24112981,"id":103329701,"diff_hunk":"@@ -296,6 +309,87 @@ public DataApiRequest(\n     }\n \n     /**\n+     * To check whether dateTime column request is first one in the sort list or not.\n+     *\n+     * @param sortColumns  map of columns and its direction\n+     *\n+     * @return True if dateTime column is first one in the sort list. False otherwise\n+     */\n+    protected Boolean isDateTimeFirstSortField(Map<String, SortDirection> sortColumns) {\n+        if (sortColumns != null) {\n+            List<String> columns = new ArrayList(sortColumns.keySet());\n+            return columns.get(0).equals(DATE_TIME_STRING);\n+        }\n+        else {\n+            return false;\n+        }\n+    }\n+\n+    /**\n+     * Method to remove the dateTime column from map of columns and its direction.\n+     *\n+     * @param sortColumns  map of columns and its direction\n+     *\n+     * @return  Map of columns and its direction without dateTime sort column\n+     */\n+    protected Map<String, SortDirection> removeDateTimeSortColumn(Map<String, SortDirection> sortColumns) {\n+        if (sortColumns != null && sortColumns.containsKey(DATE_TIME_STRING)) {\n+            sortColumns.remove(DATE_TIME_STRING);\n+            return sortColumns;\n+        }\n+        else {\n+            return sortColumns;\n+        }\n+    }\n+\n+    /**\n+     * Method to generate DateTime sort column from the map of columns and its direction.\n+     *\n+     * @param sortColumns  map of columns and its direction\n+     *\n+     * @return Instance of OrderByColumn for dateTime\n+     */\n+    protected Optional<OrderByColumn> generateDateTimeSortColumn(Map<String, SortDirection> sortColumns) {\n+\n+        if (sortColumns != null && sortColumns.containsKey(DATE_TIME_STRING)) {\n+            if (!isDateTimeFirstSortField(sortColumns)) {\n+                LOG.debug(DATE_TIME_SORT_VALUE_INVALID.logFormat());\n+                throw new BadApiRequestException(DATE_TIME_SORT_VALUE_INVALID.format());\n+            } else {\n+                return Optional.of(new OrderByColumn(DATE_TIME_STRING, sortColumns.get(DATE_TIME_STRING)));\n+            }\n+\n+        } else {\n+            return Optional.empty();\n+        }\n+    }\n+\n+    /**\n+     * Method to convert sort list to column and direction map.\n+     *\n+     * @param sorts  String of sort columns\n+     *\n+     * @return Map of columns and its direction\n+     */\n+    protected Map<String, SortDirection> generateSortColumns(String sorts) {\n+        if (sorts != null && !sorts.isEmpty()) {\n+            return Arrays.asList(sorts.split(\",\")).stream()\n+                    .map(e -> Arrays.asList(e.split(\"\\\\|\")))\n+                    .collect(Collectors.toMap(\n+                            e -> e.get(0), e -> getSortDirection(e),\n+                                    (u, v) -> {\n+                                        LOG.debug(SORT_REQUESTED_ON_DUPLICATE_COLUMN.logFormat(u));","path":"fili-core/src/main/java/com/yahoo/bard/webservice/web/DataApiRequest.java","position":124,"original_position":124,"commit_id":"6abc99ab55793ace52fddb7b66b9a48f2053e8c2","original_commit_id":"6abc99ab55793ace52fddb7b66b9a48f2053e8c2","user":{"login":"cdeszaq","id":612084,"avatar_url":"https://avatars.githubusercontent.com/u/612084?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeszaq","html_url":"https://github.com/cdeszaq","followers_url":"https://api.github.com/users/cdeszaq/followers","following_url":"https://api.github.com/users/cdeszaq/following{/other_user}","gists_url":"https://api.github.com/users/cdeszaq/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeszaq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeszaq/subscriptions","organizations_url":"https://api.github.com/users/cdeszaq/orgs","repos_url":"https://api.github.com/users/cdeszaq/repos","events_url":"https://api.github.com/users/cdeszaq/events{/privacy}","received_events_url":"https://api.github.com/users/cdeszaq/received_events","type":"User","site_admin":false},"body":"I don't think we can actually make this error check without much more indication in the change log, nor am I sure we want to add it... Previously, we were happily allowing the same sort to show up more than once (I think), and were probably doing whatever Druid did for sorting (so probably either first or last wins). Since this would technically be a breaking API change, we can't just add it in here, in case someone is relying on how this works today.","created_at":"2017-02-27T22:30:24Z","updated_at":"2017-02-27T22:30:24Z","html_url":"https://github.com/yahoo/fili/pull/178#discussion_r103329701","pull_request_url":"https://api.github.com/repos/yahoo/fili/pulls/178","_links":{"self":{"href":"https://api.github.com/repos/yahoo/fili/pulls/comments/103329701"},"html":{"href":"https://github.com/yahoo/fili/pull/178#discussion_r103329701"},"pull_request":{"href":"https://api.github.com/repos/yahoo/fili/pulls/178"}}},"pull_request":{"url":"https://api.github.com/repos/yahoo/fili/pulls/178","id":107281673,"html_url":"https://github.com/yahoo/fili/pull/178","diff_url":"https://github.com/yahoo/fili/pull/178.diff","patch_url":"https://github.com/yahoo/fili/pull/178.patch","issue_url":"https://api.github.com/repos/yahoo/fili/issues/178","number":178,"state":"open","locked":false,"title":" Added dateTime based sort feature","user":{"login":"dayamr","id":1940669,"avatar_url":"https://avatars.githubusercontent.com/u/1940669?v=3","gravatar_id":"","url":"https://api.github.com/users/dayamr","html_url":"https://github.com/dayamr","followers_url":"https://api.github.com/users/dayamr/followers","following_url":"https://api.github.com/users/dayamr/following{/other_user}","gists_url":"https://api.github.com/users/dayamr/gists{/gist_id}","starred_url":"https://api.github.com/users/dayamr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dayamr/subscriptions","organizations_url":"https://api.github.com/users/dayamr/orgs","repos_url":"https://api.github.com/users/dayamr/repos","events_url":"https://api.github.com/users/dayamr/events{/privacy}","received_events_url":"https://api.github.com/users/dayamr/received_events","type":"User","site_admin":false},"body":"When dateTime is present in the sort field, irrespective of the query type, result should be sorted based on dateTime. To achieve this, \r\n\r\n- Added `DateTimeSortMapper` to reverse the time buckets and `DateTimeSortRequestHandler` to inject to the workflow.\r\n- Added groupBy query type results to test the sorting.\r\n\r\nThis PR created on top of https://github.com/yahoo/fili/pull/170/","created_at":"2017-02-21T21:23:38Z","updated_at":"2017-02-27T22:30:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e322e052340fcaab536e39e24e4abd05ce879809","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/yahoo/fili/pulls/178/commits","review_comments_url":"https://api.github.com/repos/yahoo/fili/pulls/178/comments","review_comment_url":"https://api.github.com/repos/yahoo/fili/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yahoo/fili/issues/178/comments","statuses_url":"https://api.github.com/repos/yahoo/fili/statuses/6abc99ab55793ace52fddb7b66b9a48f2053e8c2","head":{"label":"yahoo:dateTime_based_sort_feature","ref":"dateTime_based_sort_feature","sha":"6abc99ab55793ace52fddb7b66b9a48f2053e8c2","user":{"login":"yahoo","id":16574,"avatar_url":"https://avatars.githubusercontent.com/u/16574?v=3","gravatar_id":"","url":"https://api.github.com/users/yahoo","html_url":"https://github.com/yahoo","followers_url":"https://api.github.com/users/yahoo/followers","following_url":"https://api.github.com/users/yahoo/following{/other_user}","gists_url":"https://api.github.com/users/yahoo/gists{/gist_id}","starred_url":"https://api.github.com/users/yahoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yahoo/subscriptions","organizations_url":"https://api.github.com/users/yahoo/orgs","repos_url":"https://api.github.com/users/yahoo/repos","events_url":"https://api.github.com/users/yahoo/events{/privacy}","received_events_url":"https://api.github.com/users/yahoo/received_events","type":"Organization","site_admin":false},"repo":{"id":60879636,"name":"fili","full_name":"yahoo/fili","owner":{"login":"yahoo","id":16574,"avatar_url":"https://avatars.githubusercontent.com/u/16574?v=3","gravatar_id":"","url":"https://api.github.com/users/yahoo","html_url":"https://github.com/yahoo","followers_url":"https://api.github.com/users/yahoo/followers","following_url":"https://api.github.com/users/yahoo/following{/other_user}","gists_url":"https://api.github.com/users/yahoo/gists{/gist_id}","starred_url":"https://api.github.com/users/yahoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yahoo/subscriptions","organizations_url":"https://api.github.com/users/yahoo/orgs","repos_url":"https://api.github.com/users/yahoo/repos","events_url":"https://api.github.com/users/yahoo/events{/privacy}","received_events_url":"https://api.github.com/users/yahoo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yahoo/fili","description":"Easily make RESTful web services for time series reporting with Big Data analytics engines like Druid and Hive.","fork":false,"url":"https://api.github.com/repos/yahoo/fili","forks_url":"https://api.github.com/repos/yahoo/fili/forks","keys_url":"https://api.github.com/repos/yahoo/fili/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yahoo/fili/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yahoo/fili/teams","hooks_url":"https://api.github.com/repos/yahoo/fili/hooks","issue_events_url":"https://api.github.com/repos/yahoo/fili/issues/events{/number}","events_url":"https://api.github.com/repos/yahoo/fili/events","assignees_url":"https://api.github.com/repos/yahoo/fili/assignees{/user}","branches_url":"https://api.github.com/repos/yahoo/fili/branches{/branch}","tags_url":"https://api.github.com/repos/yahoo/fili/tags","blobs_url":"https://api.github.com/repos/yahoo/fili/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yahoo/fili/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yahoo/fili/git/refs{/sha}","trees_url":"https://api.github.com/repos/yahoo/fili/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yahoo/fili/statuses/{sha}","languages_url":"https://api.github.com/repos/yahoo/fili/languages","stargazers_url":"https://api.github.com/repos/yahoo/fili/stargazers","contributors_url":"https://api.github.com/repos/yahoo/fili/contributors","subscribers_url":"https://api.github.com/repos/yahoo/fili/subscribers","subscription_url":"https://api.github.com/repos/yahoo/fili/subscription","commits_url":"https://api.github.com/repos/yahoo/fili/commits{/sha}","git_commits_url":"https://api.github.com/repos/yahoo/fili/git/commits{/sha}","comments_url":"https://api.github.com/repos/yahoo/fili/comments{/number}","issue_comment_url":"https://api.github.com/repos/yahoo/fili/issues/comments{/number}","contents_url":"https://api.github.com/repos/yahoo/fili/contents/{+path}","compare_url":"https://api.github.com/repos/yahoo/fili/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yahoo/fili/merges","archive_url":"https://api.github.com/repos/yahoo/fili/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yahoo/fili/downloads","issues_url":"https://api.github.com/repos/yahoo/fili/issues{/number}","pulls_url":"https://api.github.com/repos/yahoo/fili/pulls{/number}","milestones_url":"https://api.github.com/repos/yahoo/fili/milestones{/number}","notifications_url":"https://api.github.com/repos/yahoo/fili/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yahoo/fili/labels{/name}","releases_url":"https://api.github.com/repos/yahoo/fili/releases{/id}","deployments_url":"https://api.github.com/repos/yahoo/fili/deployments","created_at":"2016-06-10T22:07:59Z","updated_at":"2017-02-27T04:51:14Z","pushed_at":"2017-02-27T21:37:45Z","git_url":"git://github.com/yahoo/fili.git","ssh_url":"git@github.com:yahoo/fili.git","clone_url":"https://github.com/yahoo/fili.git","svn_url":"https://github.com/yahoo/fili","homepage":"","size":4583,"stargazers_count":31,"watchers_count":31,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":50,"forks":23,"open_issues":50,"watchers":31,"default_branch":"master"}},"base":{"label":"yahoo:master","ref":"master","sha":"b1beba1ed4cc2226fa0d0894771845e2f306254a","user":{"login":"yahoo","id":16574,"avatar_url":"https://avatars.githubusercontent.com/u/16574?v=3","gravatar_id":"","url":"https://api.github.com/users/yahoo","html_url":"https://github.com/yahoo","followers_url":"https://api.github.com/users/yahoo/followers","following_url":"https://api.github.com/users/yahoo/following{/other_user}","gists_url":"https://api.github.com/users/yahoo/gists{/gist_id}","starred_url":"https://api.github.com/users/yahoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yahoo/subscriptions","organizations_url":"https://api.github.com/users/yahoo/orgs","repos_url":"https://api.github.com/users/yahoo/repos","events_url":"https://api.github.com/users/yahoo/events{/privacy}","received_events_url":"https://api.github.com/users/yahoo/received_events","type":"Organization","site_admin":false},"repo":{"id":60879636,"name":"fili","full_name":"yahoo/fili","owner":{"login":"yahoo","id":16574,"avatar_url":"https://avatars.githubusercontent.com/u/16574?v=3","gravatar_id":"","url":"https://api.github.com/users/yahoo","html_url":"https://github.com/yahoo","followers_url":"https://api.github.com/users/yahoo/followers","following_url":"https://api.github.com/users/yahoo/following{/other_user}","gists_url":"https://api.github.com/users/yahoo/gists{/gist_id}","starred_url":"https://api.github.com/users/yahoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yahoo/subscriptions","organizations_url":"https://api.github.com/users/yahoo/orgs","repos_url":"https://api.github.com/users/yahoo/repos","events_url":"https://api.github.com/users/yahoo/events{/privacy}","received_events_url":"https://api.github.com/users/yahoo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/yahoo/fili","description":"Easily make RESTful web services for time series reporting with Big Data analytics engines like Druid and Hive.","fork":false,"url":"https://api.github.com/repos/yahoo/fili","forks_url":"https://api.github.com/repos/yahoo/fili/forks","keys_url":"https://api.github.com/repos/yahoo/fili/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yahoo/fili/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yahoo/fili/teams","hooks_url":"https://api.github.com/repos/yahoo/fili/hooks","issue_events_url":"https://api.github.com/repos/yahoo/fili/issues/events{/number}","events_url":"https://api.github.com/repos/yahoo/fili/events","assignees_url":"https://api.github.com/repos/yahoo/fili/assignees{/user}","branches_url":"https://api.github.com/repos/yahoo/fili/branches{/branch}","tags_url":"https://api.github.com/repos/yahoo/fili/tags","blobs_url":"https://api.github.com/repos/yahoo/fili/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yahoo/fili/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yahoo/fili/git/refs{/sha}","trees_url":"https://api.github.com/repos/yahoo/fili/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yahoo/fili/statuses/{sha}","languages_url":"https://api.github.com/repos/yahoo/fili/languages","stargazers_url":"https://api.github.com/repos/yahoo/fili/stargazers","contributors_url":"https://api.github.com/repos/yahoo/fili/contributors","subscribers_url":"https://api.github.com/repos/yahoo/fili/subscribers","subscription_url":"https://api.github.com/repos/yahoo/fili/subscription","commits_url":"https://api.github.com/repos/yahoo/fili/commits{/sha}","git_commits_url":"https://api.github.com/repos/yahoo/fili/git/commits{/sha}","comments_url":"https://api.github.com/repos/yahoo/fili/comments{/number}","issue_comment_url":"https://api.github.com/repos/yahoo/fili/issues/comments{/number}","contents_url":"https://api.github.com/repos/yahoo/fili/contents/{+path}","compare_url":"https://api.github.com/repos/yahoo/fili/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yahoo/fili/merges","archive_url":"https://api.github.com/repos/yahoo/fili/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yahoo/fili/downloads","issues_url":"https://api.github.com/repos/yahoo/fili/issues{/number}","pulls_url":"https://api.github.com/repos/yahoo/fili/pulls{/number}","milestones_url":"https://api.github.com/repos/yahoo/fili/milestones{/number}","notifications_url":"https://api.github.com/repos/yahoo/fili/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yahoo/fili/labels{/name}","releases_url":"https://api.github.com/repos/yahoo/fili/releases{/id}","deployments_url":"https://api.github.com/repos/yahoo/fili/deployments","created_at":"2016-06-10T22:07:59Z","updated_at":"2017-02-27T04:51:14Z","pushed_at":"2017-02-27T21:37:45Z","git_url":"git://github.com/yahoo/fili.git","ssh_url":"git@github.com:yahoo/fili.git","clone_url":"https://github.com/yahoo/fili.git","svn_url":"https://github.com/yahoo/fili","homepage":"","size":4583,"stargazers_count":31,"watchers_count":31,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":50,"forks":23,"open_issues":50,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yahoo/fili/pulls/178"},"html":{"href":"https://github.com/yahoo/fili/pull/178"},"issue":{"href":"https://api.github.com/repos/yahoo/fili/issues/178"},"comments":{"href":"https://api.github.com/repos/yahoo/fili/issues/178/comments"},"review_comments":{"href":"https://api.github.com/repos/yahoo/fili/pulls/178/comments"},"review_comment":{"href":"https://api.github.com/repos/yahoo/fili/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yahoo/fili/pulls/178/commits"},"statuses":{"href":"https://api.github.com/repos/yahoo/fili/statuses/6abc99ab55793ace52fddb7b66b9a48f2053e8c2"}}}}
{"actor":{"display_login":"cdeszaq"}}