You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2019/01/31 11:04:01 UTC

[GitHub] vvysotskyi commented on a change in pull request #1628: DRILL-7016: Wrong query result with RuntimeFilter enabled when order …

vvysotskyi commented on a change in pull request #1628: DRILL-7016: Wrong query result with RuntimeFilter enabled when order …
URL: https://github.com/apache/drill/pull/1628#discussion_r252620923
 
 

 ##########
 File path: exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/join/TestHashJoinJPPDCorrectness.java
 ##########
 @@ -0,0 +1,193 @@
+/*
+ * 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.physical.impl.join;
+
+import org.apache.drill.categories.SqlTest;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.proto.UserProtos;
+import org.apache.drill.test.ClusterFixture;
+import org.apache.drill.test.ClusterTest;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import static org.junit.Assert.assertTrue;
+import java.nio.file.Paths;
+
+@Category(SqlTest.class)
+public class TestHashJoinJPPDCorrectness extends ClusterTest {
+  //private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestHashJoinJPPDCorrectness.class);
+
+  private final String runtimeFilterOption = "ALTER SESSION SET `" + ExecConstants.HASHJOIN_ENABLE_RUNTIME_FILTER_KEY
+    + "` = %s";
+
+  private final String runtimeFilterWaitOption = "ALTER SESSION SET `" + ExecConstants
+    .HASHJOIN_RUNTIME_FILTER_WAITING_ENABLE_KEY + "` = %s";
+
+  private final String runtimeFilterWaitTimeOption = "ALTER SESSION SET `" + ExecConstants
+    .HASHJOIN_RUNTIME_FILTER_MAX_WAITING_TIME_KEY + "` = %d";
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    dirTestWatcher.copyResourceToRoot(Paths.get("tpchmulti"));
+    // Reduce the slice target so that there are multiple minor fragments with exchange, otherwise RuntimeFilter
+    // will not be inserted in the plan
+    startCluster(ClusterFixture.builder(dirTestWatcher)
+      .clusterSize(2)
+      .maxParallelization(1)
+      .systemOption(ExecConstants.SLICE_TARGET, 10));
+  }
+
+  @After
+  public void tearDown() {
+    client.resetSession(ExecConstants.HASHJOIN_ENABLE_RUNTIME_FILTER_KEY);
+    client.resetSession(ExecConstants.HASHJOIN_RUNTIME_FILTER_WAITING_ENABLE_KEY);
+  }
+
+  /**
+   * Test to make sure runtime filter is inserted in the plan. This is to ensure that with current cluster setup and
+   * system options distributed plan is generated rather than single fragment plan. Since in later case RuntimeFilter
+   * will not be inserted.
+   * @throws Exception
+   */
+  @Test
+  public void testRuntimeFilterPresentInPlan() throws Exception {
+    String sql = "SELECT l.n_name, r.r_name FROM dfs.`tpchmulti/nation` l, dfs.`tpchmulti/region/` r where " +
+      "l.n_regionkey = r.r_regionkey";
+
+    // don't use client.alterSession since it's an async request and hence there is no guarantee than runtime filter
+    // option will be enabled before sending the actual query
+    client.runQueriesAndLog(String.format(runtimeFilterOption, "true"));
+    UserProtos.QueryPlanFragments planFragments = client.planQuery(sql);
+    assertTrue(planFragments.toString().contains("runtime-filter"));
 
 Review comment:
   Could you please change `assertTrue(planFragments.toString().contains("runtime-filter"));` to `assertThat("some useful message", plan, containsString("runtime-filter"));` so in the case when this test will fail, assertion error message will contain the plan and expected string instead of "Expected true but was false".

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services