kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [20/24] kylin git commit: minor, avoid NPE in doPushDownQuery check
Date Tue, 25 Jul 2017 09:45:07 GMT
minor, avoid NPE in doPushDownQuery check


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/9141bffc
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/9141bffc
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/9141bffc

Branch: refs/heads/2.1.x
Commit: 9141bffc3e2732625e8f8db8d9edaa269cc34e94
Parents: 6214ab9
Author: Hongbin Ma <mahongbin@apache.org>
Authored: Tue Jul 25 11:50:35 2017 +0800
Committer: Hongbin Ma <mahongbin@apache.org>
Committed: Tue Jul 25 11:55:10 2017 +0800

----------------------------------------------------------------------
 .../test/java/org/apache/kylin/query/KylinTestBase.java |  6 +++++-
 .../org/apache/kylin/rest/service/QueryService.java     |  6 +++++-
 .../java/org/apache/kylin/rest/util/PushDownUtil.java   | 12 ++++++++----
 3 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/9141bffc/kylin-it/src/test/java/org/apache/kylin/query/KylinTestBase.java
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/java/org/apache/kylin/query/KylinTestBase.java b/kylin-it/src/test/java/org/apache/kylin/query/KylinTestBase.java
index 3634100..e1d4a44 100644
--- a/kylin-it/src/test/java/org/apache/kylin/query/KylinTestBase.java
+++ b/kylin-it/src/test/java/org/apache/kylin/query/KylinTestBase.java
@@ -263,7 +263,11 @@ public class KylinTestBase {
         } catch (SQLException sqlException) {
             List<List<String>> results = Lists.newArrayList();
             List<SelectedColumnMeta> columnMetas = Lists.newArrayList();
-            PushDownUtil.doPushDownQuery(ProjectInstance.DEFAULT_PROJECT_NAME, sql, results,
columnMetas, sqlException);
+            boolean b = PushDownUtil.doPushDownQuery(ProjectInstance.DEFAULT_PROJECT_NAME,
sql, results, columnMetas,
+                    sqlException);
+            if (!b) {
+                throw sqlException;
+            }
             return results.size();
         } finally {
             if (resultSet != null) {

http://git-wip-us.apache.org/repos/asf/kylin/blob/9141bffc/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java b/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
index 75c16bd..f4ae06c 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/QueryService.java
@@ -487,7 +487,8 @@ public class QueryService extends BasicService {
             return fakeResponse;
         }
 
-        String correctedSql = QueryUtil.massageSql(sqlRequest.getSql(), sqlRequest.getProject(),
sqlRequest.getLimit(), sqlRequest.getOffset());
+        String correctedSql = QueryUtil.massageSql(sqlRequest.getSql(), sqlRequest.getProject(),
sqlRequest.getLimit(),
+                sqlRequest.getOffset());
         if (!correctedSql.equals(sqlRequest.getSql())) {
             logger.info("The corrected query: " + correctedSql);
 
@@ -792,6 +793,9 @@ public class QueryService extends BasicService {
         } catch (SQLException sqlException) {
             isPushDown = PushDownUtil.doPushDownQuery(sqlRequest.getProject(), correctedSql,
results, columnMetas,
                     sqlException);
+            if (!isPushDown) {
+                throw sqlException;
+            }
         } finally {
             close(resultSet, stat, conn);
         }

http://git-wip-us.apache.org/repos/asf/kylin/blob/9141bffc/server-base/src/main/java/org/apache/kylin/rest/util/PushDownUtil.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/util/PushDownUtil.java b/server-base/src/main/java/org/apache/kylin/rest/util/PushDownUtil.java
index 5d7f47a..0802718 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/util/PushDownUtil.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/util/PushDownUtil.java
@@ -49,11 +49,15 @@ public class PushDownUtil {
     public static boolean doPushDownQuery(String project, String sql, List<List<String>>
results,
             List<SelectedColumnMeta> columnMetas, SQLException sqlException) throws
Exception {
 
-        boolean isExpectedCause = (ExceptionUtils.getRootCause(sqlException).getClass()
-                .equals(NoRealizationFoundException.class));
         KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
+        if (!kylinConfig.isPushDownEnabled()) {
+            return false;
+        }
+
+        Throwable rootCause = ExceptionUtils.getRootCause(sqlException);
+        boolean isExpectedCause = rootCause != null && (rootCause.getClass().equals(NoRealizationFoundException.class));
 
-        if (isExpectedCause && kylinConfig.isPushDownEnabled()) {
+        if (isExpectedCause) {
 
             logger.info("Query failed to utilize pre-calculation, routing to other engines",
sqlException);
             IPushDownRunner runner = (IPushDownRunner) ClassUtil.newInstance(kylinConfig.getPushDownRunnerClassName());
@@ -78,7 +82,7 @@ public class PushDownUtil {
 
             return true;
         } else {
-            throw sqlException;
+            return false;
         }
     }
 


Mime
View raw message