Github user hnfgns commented on a diff in the pull request:

    https://github.com/apache/drill/pull/368#discussion_r61494824
  
    --- Diff: 
exec/java-exec/src/test/java/org/apache/drill/exec/DrillSeparatePlanningTest.java
 ---
    @@ -0,0 +1,350 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.drill.exec;
    +
    +import static org.junit.Assert.*;
    +import io.netty.buffer.DrillBuf;
    +
    +import java.util.Iterator;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +import java.util.Properties;
    +import java.util.concurrent.ExecutionException;
    +
    +import org.apache.drill.BaseTestQuery;
    +import org.apache.drill.common.DrillAutoCloseables;
    +import org.apache.drill.common.exceptions.UserException;
    +import org.apache.drill.common.util.TestTools;
    +import org.apache.drill.exec.client.DrillClient;
    +import org.apache.drill.exec.client.PrintingResultsListener;
    +import org.apache.drill.exec.client.QuerySubmitter.Format;
    +import org.apache.drill.exec.exception.SchemaChangeException;
    +import org.apache.drill.exec.memory.BufferAllocator;
    +import org.apache.drill.exec.proto.BitControl.PlanFragment;
    +import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
    +import org.apache.drill.exec.proto.UserBitShared.QueryData;
    +import org.apache.drill.exec.proto.UserBitShared.QueryId;
    +import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
    +import org.apache.drill.exec.proto.UserBitShared.QueryType;
    +import org.apache.drill.exec.proto.UserProtos.QueryPlanFragments;
    +import org.apache.drill.exec.record.RecordBatchLoader;
    +import org.apache.drill.exec.record.VectorWrapper;
    +import org.apache.drill.exec.rpc.ConnectionThrottle;
    +import org.apache.drill.exec.rpc.DrillRpcFuture;
    +import org.apache.drill.exec.rpc.RpcException;
    +import org.apache.drill.exec.rpc.user.AwaitableUserResultsListener;
    +import org.apache.drill.exec.rpc.user.QueryDataBatch;
    +import org.apache.drill.exec.rpc.user.UserResultsListener;
    +import org.apache.drill.exec.util.VectorUtil;
    +import org.apache.drill.exec.vector.ValueVector;
    +import org.junit.Test;
    +
    +import com.google.common.collect.Lists;
    +import com.google.common.collect.Maps;
    +
    +/**
    + * Class to test different planning use cases (separate form query 
execution)
    + *
    + */
    +public class DrillSeparatePlanningTest extends BaseTestQuery {
    +
    +  static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(DrillSeparatePlanningTest.class);
    +
    +  static final String WORKING_PATH = TestTools.getWorkingPath();
    +  static final String TEST_RES_PATH = WORKING_PATH + "/src/test/resources";
    +
    +  //final String query = "SELECT sales_city, COUNT(*) cnt FROM 
cp.`region.json` GROUP BY sales_city";
    +  //final String query = "SELECT * FROM cp.`employee.json` where  
employee_id > 1 and  employee_id < 1000";
    +  //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";
    +  //final String query = "SELECT sum(o_totalprice) FROM 
dfs.tmp.`multilevel` where dir0 = 1995 and o_orderkey > 100 and o_orderkey < 
1000";
    +  //final String query = "SELECT o_orderkey FROM dfs.tmp.`multilevel` 
order by o_orderkey";
    +  //final String query = "SELECT dir1, sum(o_totalprice) FROM 
dfs.tmp.`multilevel` where dir0 = 1995 group by dir1 order by dir1";
    +  //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);
    +
    +
    +  @Test(timeout=30000)
    +  public void testSingleFragmentQuery() throws Exception {
    +    final String query = "SELECT * FROM cp.`employee.json` where  
employee_id > 1 and  employee_id < 1000";
    +
    +    QueryPlanFragments planFragments = getFragmentsHelper(query);
    +
    +    assertNotNull(planFragments);
    +
    +    assertEquals(1, planFragments.getFragmentsCount());
    +    assertTrue(planFragments.getFragments(0).getLeafFragment());
    +
    +    getResultsHelper(planFragments);
    +  }
    +
    +  @Test(timeout=30000)
    +  public void testMultiMinorFragmentSimpleQuery() throws Exception {
    +    final String query = String.format("SELECT o_orderkey FROM 
dfs_test.`%s/multilevel/json`", TEST_RES_PATH);
    +
    +    QueryPlanFragments planFragments = getFragmentsHelper(query);
    +
    +    assertNotNull(planFragments);
    +
    +    assertTrue((planFragments.getFragmentsCount() > 1));
    +
    +    for ( PlanFragment planFragment : planFragments.getFragmentsList()) {
    +      assertTrue(planFragment.getLeafFragment());
    +    }
    +
    +    getResultsHelper(planFragments);
    +  }
    +
    +  @Test(timeout=30000)
    +  public void testMultiMinorFragmentComplexQuery() throws Exception {
    +    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);
    +
    +    QueryPlanFragments planFragments = getFragmentsHelper(query);
    +
    +    assertNotNull(planFragments);
    +
    +    assertTrue((planFragments.getFragmentsCount() > 1));
    +
    +    for ( PlanFragment planFragment : planFragments.getFragmentsList()) {
    +      assertTrue(planFragment.getLeafFragment());
    +    }
    +
    +    getResultsHelper(planFragments);
    +
    +  }
    +
    +  @Test(timeout=30000)
    +  public void testPlanningNoSplit() throws Exception {
    +    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);
    +
    +    updateTestCluster(2, config);
    +
    +    List<QueryDataBatch> results = client.runQuery(QueryType.SQL, "alter 
session set `planner.slice_target`=1");
    +    for(QueryDataBatch batch : results) {
    +      batch.release();
    +    }
    +
    +    DrillRpcFuture<QueryPlanFragments> queryFragmentsFutures = 
client.planQuery(QueryType.SQL, query, false);
    +
    +    final QueryPlanFragments planFragments = queryFragmentsFutures.get();
    +
    +    assertNotNull(planFragments);
    +
    +    assertTrue((planFragments.getFragmentsCount() > 1));
    +
    +    PlanFragment rootFragment = planFragments.getFragments(0);
    +    assertFalse(rootFragment.getLeafFragment());
    +
    +    getCombinedResultsHelper(planFragments);
    +
    +    client.close();
    --- End diff --
    
    BaseTestQuery closes client at the end of suite. We should not close the 
client. I would be surprised if your unit tests passed as it is 👍 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to