{"action":"created","comment":{"url":"https://api.github.com/repos/apache/drill/pulls/comments/61521260","id":61521260,"diff_hunk":"@@ -0,0 +1,350 @@\n+/**\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package org.apache.drill.exec;\n+\n+import static org.junit.Assert.*;\n+import io.netty.buffer.DrillBuf;\n+\n+import java.util.Iterator;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Map.Entry;\n+import java.util.Properties;\n+import java.util.concurrent.ExecutionException;\n+\n+import org.apache.drill.BaseTestQuery;\n+import org.apache.drill.common.DrillAutoCloseables;\n+import org.apache.drill.common.exceptions.UserException;\n+import org.apache.drill.common.util.TestTools;\n+import org.apache.drill.exec.client.DrillClient;\n+import org.apache.drill.exec.client.PrintingResultsListener;\n+import org.apache.drill.exec.client.QuerySubmitter.Format;\n+import org.apache.drill.exec.exception.SchemaChangeException;\n+import org.apache.drill.exec.memory.BufferAllocator;\n+import org.apache.drill.exec.proto.BitControl.PlanFragment;\n+import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;\n+import org.apache.drill.exec.proto.UserBitShared.QueryData;\n+import org.apache.drill.exec.proto.UserBitShared.QueryId;\n+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;\n+import org.apache.drill.exec.proto.UserBitShared.QueryType;\n+import org.apache.drill.exec.proto.UserProtos.QueryPlanFragments;\n+import org.apache.drill.exec.record.RecordBatchLoader;\n+import org.apache.drill.exec.record.VectorWrapper;\n+import org.apache.drill.exec.rpc.ConnectionThrottle;\n+import org.apache.drill.exec.rpc.DrillRpcFuture;\n+import org.apache.drill.exec.rpc.RpcException;\n+import org.apache.drill.exec.rpc.user.AwaitableUserResultsListener;\n+import org.apache.drill.exec.rpc.user.QueryDataBatch;\n+import org.apache.drill.exec.rpc.user.UserResultsListener;\n+import org.apache.drill.exec.util.VectorUtil;\n+import org.apache.drill.exec.vector.ValueVector;\n+import org.junit.Test;\n+\n+import com.google.common.collect.Lists;\n+import com.google.common.collect.Maps;\n+\n+/**\n+ * Class to test different planning use cases (separate form query execution)\n+ *\n+ */\n+public class DrillSeparatePlanningTest extends BaseTestQuery {\n+\n+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillSeparatePlanningTest.class);\n+\n+  static final String WORKING_PATH = TestTools.getWorkingPath();\n+  static final String TEST_RES_PATH = WORKING_PATH + \"/src/test/resources\";\n+\n+  //final String query = \"SELECT sales_city, COUNT(*) cnt FROM cp.`region.json` GROUP BY sales_city\";\n+  //final String query = \"SELECT * FROM cp.`employee.json` where  employee_id > 1 and  employee_id < 1000\";\n+  //final String query = \"SELECT o_orderkey, o_custkey FROM dfs.tmp.`multilevel` where dir0 = 1995 and o_orderkey > 100 and o_orderkey < 1000 limit 5\";\n+  //final String query = \"SELECT sum(o_totalprice) FROM dfs.tmp.`multilevel` where dir0 = 1995 and o_orderkey > 100 and o_orderkey < 1000\";\n+  //final String query = \"SELECT o_orderkey FROM dfs.tmp.`multilevel` order by o_orderkey\";\n+  //final String query = \"SELECT dir1, sum(o_totalprice) FROM dfs.tmp.`multilevel` where dir0 = 1995 group by dir1 order by dir1\";\n+  //final String query = String.format(\"SELECT dir0, sum(o_totalprice) FROM dfs_test.`%s/multilevel/json` group by dir0 order by dir0\", TEST_RES_PATH);\n+\n+\n+  @Test(timeout=30000)\n+  public void testSingleFragmentQuery() throws Exception {\n+    final String query = \"SELECT * FROM cp.`employee.json` where  employee_id > 1 and  employee_id < 1000\";\n+\n+    QueryPlanFragments planFragments = getFragmentsHelper(query);\n+\n+    assertNotNull(planFragments);\n+\n+    assertEquals(1, planFragments.getFragmentsCount());\n+    assertTrue(planFragments.getFragments(0).getLeafFragment());\n+\n+    getResultsHelper(planFragments);\n+  }\n+\n+  @Test(timeout=30000)\n+  public void testMultiMinorFragmentSimpleQuery() throws Exception {\n+    final String query = String.format(\"SELECT o_orderkey FROM dfs_test.`%s/multilevel/json`\", TEST_RES_PATH);\n+\n+    QueryPlanFragments planFragments = getFragmentsHelper(query);\n+\n+    assertNotNull(planFragments);\n+\n+    assertTrue((planFragments.getFragmentsCount() > 1));\n+\n+    for ( PlanFragment planFragment : planFragments.getFragmentsList()) {\n+      assertTrue(planFragment.getLeafFragment());\n+    }\n+\n+    getResultsHelper(planFragments);\n+  }\n+\n+  @Test(timeout=30000)\n+  public void testMultiMinorFragmentComplexQuery() throws Exception {\n+    final String query = String.format(\"SELECT dir0, sum(o_totalprice) FROM dfs_test.`%s/multilevel/json` group by dir0 order by dir0\", TEST_RES_PATH);\n+\n+    QueryPlanFragments planFragments = getFragmentsHelper(query);\n+\n+    assertNotNull(planFragments);\n+\n+    assertTrue((planFragments.getFragmentsCount() > 1));\n+\n+    for ( PlanFragment planFragment : planFragments.getFragmentsList()) {\n+      assertTrue(planFragment.getLeafFragment());\n+    }\n+\n+    getResultsHelper(planFragments);\n+\n+  }\n+\n+  @Test(timeout=30000)\n+  public void testPlanningNoSplit() throws Exception {\n+    final String query = String.format(\"SELECT dir0, sum(o_totalprice) FROM dfs_test.`%s/multilevel/json` group by dir0 order by dir0\", TEST_RES_PATH);\n+\n+    updateTestCluster(2, config);\n+\n+    List<QueryDataBatch> results = client.runQuery(QueryType.SQL, \"alter session set `planner.slice_target`=1\");\n+    for(QueryDataBatch batch : results) {\n+      batch.release();\n+    }\n+\n+    DrillRpcFuture<QueryPlanFragments> queryFragmentsFutures = client.planQuery(QueryType.SQL, query, false);\n+\n+    final QueryPlanFragments planFragments = queryFragmentsFutures.get();\n+\n+    assertNotNull(planFragments);\n+\n+    assertTrue((planFragments.getFragmentsCount() > 1));\n+\n+    PlanFragment rootFragment = planFragments.getFragments(0);\n+    assertFalse(rootFragment.getLeafFragment());\n+\n+    getCombinedResultsHelper(planFragments);\n+\n+    client.close();","path":"exec/java-exec/src/test/java/org/apache/drill/exec/DrillSeparatePlanningTest.java","position":154,"original_position":154,"commit_id":"66412a999ca502c8545b539847faafc20a33518f","original_commit_id":"66412a999ca502c8545b539847faafc20a33518f","user":{"login":"hnfgns","id":3476250,"avatar_url":"https://avatars.githubusercontent.com/u/3476250?v=3","gravatar_id":"","url":"https://api.github.com/users/hnfgns","html_url":"https://github.com/hnfgns","followers_url":"https://api.github.com/users/hnfgns/followers","following_url":"https://api.github.com/users/hnfgns/following{/other_user}","gists_url":"https://api.github.com/users/hnfgns/gists{/gist_id}","starred_url":"https://api.github.com/users/hnfgns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hnfgns/subscriptions","organizations_url":"https://api.github.com/users/hnfgns/orgs","repos_url":"https://api.github.com/users/hnfgns/repos","events_url":"https://api.github.com/users/hnfgns/events{/privacy}","received_events_url":"https://api.github.com/users/hnfgns/received_events","type":"User","site_admin":false},"body":"Thanks for the clarification. Sounds weird/buggish to me that tests are not failing even after closing the client.","created_at":"2016-04-29T00:00:40Z","updated_at":"2016-04-29T00:00:40Z","html_url":"https://github.com/apache/drill/pull/368#discussion_r61521260","pull_request_url":"https://api.github.com/repos/apache/drill/pulls/368","_links":{"self":{"href":"https://api.github.com/repos/apache/drill/pulls/comments/61521260"},"html":{"href":"https://github.com/apache/drill/pull/368#discussion_r61521260"},"pull_request":{"href":"https://api.github.com/repos/apache/drill/pulls/368"}}},"pull_request":{"url":"https://api.github.com/repos/apache/drill/pulls/368","id":58565449,"html_url":"https://github.com/apache/drill/pull/368","diff_url":"https://github.com/apache/drill/pull/368.diff","patch_url":"https://github.com/apache/drill/pull/368.patch","issue_url":"https://api.github.com/repos/apache/drill/issues/368","number":368,"state":"open","locked":false,"title":"DRILL-4132 Ability to submit simple type of physical plan directly to…","user":{"login":"yufeldman","id":3076038,"avatar_url":"https://avatars.githubusercontent.com/u/3076038?v=3","gravatar_id":"","url":"https://api.github.com/users/yufeldman","html_url":"https://github.com/yufeldman","followers_url":"https://api.github.com/users/yufeldman/followers","following_url":"https://api.github.com/users/yufeldman/following{/other_user}","gists_url":"https://api.github.com/users/yufeldman/gists{/gist_id}","starred_url":"https://api.github.com/users/yufeldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yufeldman/subscriptions","organizations_url":"https://api.github.com/users/yufeldman/orgs","repos_url":"https://api.github.com/users/yufeldman/repos","events_url":"https://api.github.com/users/yufeldman/events{/privacy}","received_events_url":"https://api.github.com/users/yufeldman/received_events","type":"User","site_admin":false},"body":"… EndPoint DrillBit for execution.\r\n\r\nThere are multiple changes to achieve this:\r\n1. During physical planning split single plan into multiple based on the number of minor fragments of the Leaf Major fragment.\r\n   a. Removing exchange operators during planning\r\n   b. Producing just root fragments (that will be also leaf fragments)\r\n2. Each fragment can be executed against Drillbit it is assigned to, so to keep locality\r\nDesign document can be found in the JIRA: DRILL-4132","created_at":"2016-02-08T02:10:09Z","updated_at":"2016-04-29T00:00:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4cd2412addc61bbece5c381d4bb8c1d9f406b063","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/drill/pulls/368/commits","review_comments_url":"https://api.github.com/repos/apache/drill/pulls/368/comments","review_comment_url":"https://api.github.com/repos/apache/drill/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/drill/issues/368/comments","statuses_url":"https://api.github.com/repos/apache/drill/statuses/66412a999ca502c8545b539847faafc20a33518f","head":{"label":"yufeldman:DRILL-4132","ref":"DRILL-4132","sha":"66412a999ca502c8545b539847faafc20a33518f","user":{"login":"yufeldman","id":3076038,"avatar_url":"https://avatars.githubusercontent.com/u/3076038?v=3","gravatar_id":"","url":"https://api.github.com/users/yufeldman","html_url":"https://github.com/yufeldman","followers_url":"https://api.github.com/users/yufeldman/followers","following_url":"https://api.github.com/users/yufeldman/following{/other_user}","gists_url":"https://api.github.com/users/yufeldman/gists{/gist_id}","starred_url":"https://api.github.com/users/yufeldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yufeldman/subscriptions","organizations_url":"https://api.github.com/users/yufeldman/orgs","repos_url":"https://api.github.com/users/yufeldman/repos","events_url":"https://api.github.com/users/yufeldman/events{/privacy}","received_events_url":"https://api.github.com/users/yufeldman/received_events","type":"User","site_admin":false},"repo":{"id":23401056,"name":"incubator-drill","full_name":"yufeldman/incubator-drill","owner":{"login":"yufeldman","id":3076038,"avatar_url":"https://avatars.githubusercontent.com/u/3076038?v=3","gravatar_id":"","url":"https://api.github.com/users/yufeldman","html_url":"https://github.com/yufeldman","followers_url":"https://api.github.com/users/yufeldman/followers","following_url":"https://api.github.com/users/yufeldman/following{/other_user}","gists_url":"https://api.github.com/users/yufeldman/gists{/gist_id}","starred_url":"https://api.github.com/users/yufeldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yufeldman/subscriptions","organizations_url":"https://api.github.com/users/yufeldman/orgs","repos_url":"https://api.github.com/users/yufeldman/repos","events_url":"https://api.github.com/users/yufeldman/events{/privacy}","received_events_url":"https://api.github.com/users/yufeldman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yufeldman/incubator-drill","description":"Mirror of Apache Drill (Incubating)","fork":true,"url":"https://api.github.com/repos/yufeldman/incubator-drill","forks_url":"https://api.github.com/repos/yufeldman/incubator-drill/forks","keys_url":"https://api.github.com/repos/yufeldman/incubator-drill/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yufeldman/incubator-drill/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yufeldman/incubator-drill/teams","hooks_url":"https://api.github.com/repos/yufeldman/incubator-drill/hooks","issue_events_url":"https://api.github.com/repos/yufeldman/incubator-drill/issues/events{/number}","events_url":"https://api.github.com/repos/yufeldman/incubator-drill/events","assignees_url":"https://api.github.com/repos/yufeldman/incubator-drill/assignees{/user}","branches_url":"https://api.github.com/repos/yufeldman/incubator-drill/branches{/branch}","tags_url":"https://api.github.com/repos/yufeldman/incubator-drill/tags","blobs_url":"https://api.github.com/repos/yufeldman/incubator-drill/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yufeldman/incubator-drill/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yufeldman/incubator-drill/git/refs{/sha}","trees_url":"https://api.github.com/repos/yufeldman/incubator-drill/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yufeldman/incubator-drill/statuses/{sha}","languages_url":"https://api.github.com/repos/yufeldman/incubator-drill/languages","stargazers_url":"https://api.github.com/repos/yufeldman/incubator-drill/stargazers","contributors_url":"https://api.github.com/repos/yufeldman/incubator-drill/contributors","subscribers_url":"https://api.github.com/repos/yufeldman/incubator-drill/subscribers","subscription_url":"https://api.github.com/repos/yufeldman/incubator-drill/subscription","commits_url":"https://api.github.com/repos/yufeldman/incubator-drill/commits{/sha}","git_commits_url":"https://api.github.com/repos/yufeldman/incubator-drill/git/commits{/sha}","comments_url":"https://api.github.com/repos/yufeldman/incubator-drill/comments{/number}","issue_comment_url":"https://api.github.com/repos/yufeldman/incubator-drill/issues/comments{/number}","contents_url":"https://api.github.com/repos/yufeldman/incubator-drill/contents/{+path}","compare_url":"https://api.github.com/repos/yufeldman/incubator-drill/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yufeldman/incubator-drill/merges","archive_url":"https://api.github.com/repos/yufeldman/incubator-drill/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yufeldman/incubator-drill/downloads","issues_url":"https://api.github.com/repos/yufeldman/incubator-drill/issues{/number}","pulls_url":"https://api.github.com/repos/yufeldman/incubator-drill/pulls{/number}","milestones_url":"https://api.github.com/repos/yufeldman/incubator-drill/milestones{/number}","notifications_url":"https://api.github.com/repos/yufeldman/incubator-drill/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yufeldman/incubator-drill/labels{/name}","releases_url":"https://api.github.com/repos/yufeldman/incubator-drill/releases{/id}","deployments_url":"https://api.github.com/repos/yufeldman/incubator-drill/deployments","created_at":"2014-08-27T18:38:30Z","updated_at":"2016-01-15T19:56:11Z","pushed_at":"2016-04-28T06:43:54Z","git_url":"git://github.com/yufeldman/incubator-drill.git","ssh_url":"git@github.com:yufeldman/incubator-drill.git","clone_url":"https://github.com/yufeldman/incubator-drill.git","svn_url":"https://github.com/yufeldman/incubator-drill","homepage":null,"size":22375,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"5705d45095bd89fb9d1e7b3b3e12c34e74930c4c","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":5683653,"name":"drill","full_name":"apache/drill","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/drill","description":"Mirror of Apache Drill","fork":false,"url":"https://api.github.com/repos/apache/drill","forks_url":"https://api.github.com/repos/apache/drill/forks","keys_url":"https://api.github.com/repos/apache/drill/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/drill/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/drill/teams","hooks_url":"https://api.github.com/repos/apache/drill/hooks","issue_events_url":"https://api.github.com/repos/apache/drill/issues/events{/number}","events_url":"https://api.github.com/repos/apache/drill/events","assignees_url":"https://api.github.com/repos/apache/drill/assignees{/user}","branches_url":"https://api.github.com/repos/apache/drill/branches{/branch}","tags_url":"https://api.github.com/repos/apache/drill/tags","blobs_url":"https://api.github.com/repos/apache/drill/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/drill/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/drill/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/drill/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/drill/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/drill/languages","stargazers_url":"https://api.github.com/repos/apache/drill/stargazers","contributors_url":"https://api.github.com/repos/apache/drill/contributors","subscribers_url":"https://api.github.com/repos/apache/drill/subscribers","subscription_url":"https://api.github.com/repos/apache/drill/subscription","commits_url":"https://api.github.com/repos/apache/drill/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/drill/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/drill/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/drill/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/drill/contents/{+path}","compare_url":"https://api.github.com/repos/apache/drill/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/drill/merges","archive_url":"https://api.github.com/repos/apache/drill/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/drill/downloads","issues_url":"https://api.github.com/repos/apache/drill/issues{/number}","pulls_url":"https://api.github.com/repos/apache/drill/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/drill/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/drill/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/drill/labels{/name}","releases_url":"https://api.github.com/repos/apache/drill/releases{/id}","deployments_url":"https://api.github.com/repos/apache/drill/deployments","created_at":"2012-09-05T07:00:26Z","updated_at":"2016-04-28T12:13:01Z","pushed_at":"2016-04-28T17:29:21Z","git_url":"git://github.com/apache/drill.git","ssh_url":"git@github.com:apache/drill.git","clone_url":"https://github.com/apache/drill.git","svn_url":"https://github.com/apache/drill","homepage":"","size":48605,"stargazers_count":603,"watchers_count":603,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":419,"mirror_url":"git://git.apache.org/drill.git","open_issues_count":111,"forks":419,"open_issues":111,"watchers":603,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/drill/pulls/368"},"html":{"href":"https://github.com/apache/drill/pull/368"},"issue":{"href":"https://api.github.com/repos/apache/drill/issues/368"},"comments":{"href":"https://api.github.com/repos/apache/drill/issues/368/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/drill/pulls/368/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/drill/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/drill/pulls/368/commits"},"statuses":{"href":"https://api.github.com/repos/apache/drill/statuses/66412a999ca502c8545b539847faafc20a33518f"}}}}