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

xxyu pushed a commit to branch kylin-on-parquet-v2
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/kylin-on-parquet-v2 by this 
push:
     new 44402d3  KYLIN-4853 QueryPreparedStatementCache invalid in Spark Query 
Engine. (#1532)
44402d3 is described below

commit 44402d3c39cecff9a71dea2edc85bae72b8ab224
Author: zhengshengjun <74281684+zhengsheng...@users.noreply.github.com>
AuthorDate: Tue Jan 5 18:31:16 2021 +0800

    KYLIN-4853 QueryPreparedStatementCache invalid in Spark Query Engine. 
(#1532)
---
 .../java/org/apache/kylin/rest/service/QueryService.java   | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

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 0801432..855174b 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
@@ -703,11 +703,23 @@ public class QueryService extends BasicService {
                 if (getConfig().isQueryPreparedStatementCacheEnable() && 
prepareSqlRequest.isEnableStatementCache()) {
                     try {
                         preparedContext = 
preparedContextPool.borrowObject(preparedContextKey);
+
+                        // preparedContext initialized by current thread, put 
relNode and resultType into cache
+                        if (preparedContext.olapRel == null) {
+                            preparedContext.olapRel = 
QueryContextFacade.current().getOlapRel();
+                            preparedContext.resultType = 
(QueryContextFacade.current().getResultType());
+                        } else {
+                            //set cached RelNode and ResultType into current 
QueryContext
+                            
QueryContextFacade.current().setOlapRel(preparedContext.olapRel);
+                            
QueryContextFacade.current().setResultType(preparedContext.resultType);
+                        }
+
                         borrowPrepareContext = true;
                     } catch (NoSuchElementException noElementException) {
                         borrowPrepareContext = false;
                         preparedContext = 
createPreparedContext(sqlRequest.getProject(), sqlRequest.getSql());
                     }
+
                     for (OLAPContext olapContext : 
preparedContext.olapContexts) {
                         resetRealizationInContext(olapContext);
                         OLAPContext.registerContext(olapContext);
@@ -1404,6 +1416,8 @@ public class QueryService extends BasicService {
         private Connection conn;
         private PreparedStatement preparedStatement;
         private Collection<OLAPContext> olapContexts;
+        private Object olapRel;
+        private Object resultType;
 
         public PreparedContext(Connection conn, PreparedStatement 
preparedStatement,
                 Collection<OLAPContext> olapContexts) {

Reply via email to