You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by cg...@apache.org on 2022/05/27 00:16:41 UTC

[drill] branch master updated: DRILL-8237: Limit is not pushed down to scan for MSSQL (#2564)

This is an automated email from the ASF dual-hosted git repository.

cgivre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git


The following commit(s) were added to refs/heads/master by this push:
     new 599f0bdab7 DRILL-8237: Limit is not pushed down to scan for MSSQL (#2564)
599f0bdab7 is described below

commit 599f0bdab7ba340939c21e5da2fd5270b3144a89
Author: Volodymyr Vysotskyi <vv...@gmail.com>
AuthorDate: Fri May 27 03:16:33 2022 +0300

    DRILL-8237: Limit is not pushed down to scan for MSSQL (#2564)
---
 .../org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMSSQL.java    | 5 +----
 .../org/apache/drill/exec/store/enumerable/plan/DrillJdbcSort.java   | 3 ++-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMSSQL.java b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMSSQL.java
index c759dfe978..fb590266ee 100644
--- a/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMSSQL.java
+++ b/contrib/storage-jdbc/src/test/java/org/apache/drill/exec/store/jdbc/TestJdbcPluginWithMSSQL.java
@@ -32,7 +32,6 @@ import org.apache.drill.test.rowSet.RowSetUtilities;
 import org.junit.AfterClass;
 import org.junit.Assume;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.testcontainers.containers.MSSQLServerContainer;
@@ -50,7 +49,7 @@ import static org.junit.Assert.assertEquals;
 @Category(JdbcStorageTest.class)
 public class TestJdbcPluginWithMSSQL extends ClusterTest {
 
-  private static MSSQLServerContainer jdbcContainer;
+  private static MSSQLServerContainer<?> jdbcContainer;
 
   @BeforeClass
   public static void initMSSQL() throws Exception {
@@ -317,8 +316,6 @@ public class TestJdbcPluginWithMSSQL extends ClusterTest {
   }
 
   @Test
-  @Ignore
-  // TODO: Enable once the push down logic has been clarified.
   public void testLimitPushDownWithOffset() throws Exception {
     String query = "select person_id, first_name from mssql.dbo.person limit 100 offset 10";
     queryBuilder()
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/enumerable/plan/DrillJdbcSort.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/enumerable/plan/DrillJdbcSort.java
index 1f15ce3388..a1ab014f89 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/enumerable/plan/DrillJdbcSort.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/enumerable/plan/DrillJdbcSort.java
@@ -42,7 +42,8 @@ public class DrillJdbcSort extends JdbcRules.JdbcSort {
       double numRows = mq.getRowCount(this);
       double cpuCost = DrillCostBase.COMPARE_CPU_COST * numRows;
       DrillCostBase.DrillCostFactory costFactory = (DrillCostBase.DrillCostFactory) planner.getCostFactory();
-      return costFactory.makeCost(numRows, cpuCost, 0, 0);
+      // adjust cost to handle the case when the original limit was split
+      return costFactory.makeCost(numRows, cpuCost, 0, 0).multiplyBy(0.1);
     }
     return super.computeSelfCost(planner, mq);
   }