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

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


The following commit(s) were added to refs/heads/master by this push:
     new 8b2bcfa9b [KYUUBI #6316] Support switching jdbc dialect based on 
session conf
8b2bcfa9b is described below

commit 8b2bcfa9b641a81195bc78e2867c00be01509f8f
Author: senmiaoliu <[email protected]>
AuthorDate: Thu Apr 18 21:33:55 2024 +0800

    [KYUUBI #6316] Support switching jdbc dialect based on session conf
    
    # :mag: Description
    ## Issue References ๐Ÿ”—
    
    This pull request fixes #6316
    
    ## Describe Your Solution ๐Ÿ”ง
    
    Now JDBC engine using the overlay conf as session conf,  The 
ConnectionProvider will switch depending on the session conf. Therefore, we 
should also select the JDBC dialect based on the session conf.
    
    ## Types of changes :bookmark:
    
    - [ ] Bugfix (non-breaking change which fixes an issue)
    - [x] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
    
    ## Test Plan ๐Ÿงช
    
    #### Behavior Without This Pull Request :coffin:
    
    #### Behavior With This Pull Request :tada:
    
    #### Related Unit Tests
    
    ---
    
    # Checklist ๐Ÿ“
    
    - [x] This patch was not authored or co-authored using [Generative 
Tooling](https://www.apache.org/legal/generative-tooling.html)
    
    **Be nice. Be informative.**
    
    Closes #6202 from lsm1/branch-support-switch-provider.
    
    Closes #6316
    
    adac7852a [senmiaoliu] support switch dialect of session
    
    Authored-by: senmiaoliu <[email protected]>
    Signed-off-by: Shaoyun Chen <[email protected]>
---
 .../org/apache/kyuubi/engine/jdbc/operation/JdbcOperation.scala   | 3 ++-
 .../org/apache/kyuubi/engine/jdbc/session/JdbcSessionImpl.scala   | 8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/operation/JdbcOperation.scala
 
b/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/operation/JdbcOperation.scala
index 5e5819adb..555725944 100644
--- 
a/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/operation/JdbcOperation.scala
+++ 
b/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/operation/JdbcOperation.scala
@@ -20,6 +20,7 @@ import org.apache.kyuubi.{KyuubiSQLException, Utils}
 import org.apache.kyuubi.config.KyuubiConf
 import org.apache.kyuubi.engine.jdbc.dialect.{JdbcDialect, JdbcDialects}
 import org.apache.kyuubi.engine.jdbc.schema.{Row, Schema}
+import org.apache.kyuubi.engine.jdbc.session.JdbcSessionImpl
 import org.apache.kyuubi.operation.{AbstractOperation, FetchIterator, 
OperationState}
 import org.apache.kyuubi.operation.FetchOrientation.{FETCH_FIRST, FETCH_NEXT, 
FETCH_PRIOR, FetchOrientation}
 import org.apache.kyuubi.session.Session
@@ -31,7 +32,7 @@ abstract class JdbcOperation(session: Session) extends 
AbstractOperation(session
 
   protected var iter: FetchIterator[Row] = _
 
-  protected lazy val conf: KyuubiConf = session.sessionManager.getConf
+  protected lazy val conf: KyuubiConf = 
session.asInstanceOf[JdbcSessionImpl].sessionConf
 
   protected lazy val dialect: JdbcDialect = JdbcDialects.get(conf)
 
diff --git 
a/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/session/JdbcSessionImpl.scala
 
b/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/session/JdbcSessionImpl.scala
index 9e2ffe858..fe589ee8d 100644
--- 
a/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/session/JdbcSessionImpl.scala
+++ 
b/externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/session/JdbcSessionImpl.scala
@@ -45,7 +45,7 @@ class JdbcSessionImpl(
 
   private var databaseMetaData: DatabaseMetaData = _
 
-  private val kyuubiConf: KyuubiConf = normalizeConf
+  val sessionConf: KyuubiConf = normalizeConf
 
   private def normalizeConf: KyuubiConf = {
     val kyuubiConf = sessionManager.getConf.clone
@@ -60,13 +60,13 @@ class JdbcSessionImpl(
   override def open(): Unit = {
     info(s"Starting to open jdbc session.")
     if (sessionConnection == null) {
-      sessionConnection = ConnectionProvider.create(kyuubiConf)
+      sessionConnection = ConnectionProvider.create(sessionConf)
       databaseMetaData = sessionConnection.getMetaData
     }
     KyuubiJdbcUtils.initializeJdbcSession(
-      kyuubiConf,
+      sessionConf,
       sessionConnection,
-      kyuubiConf.get(ENGINE_JDBC_SESSION_INITIALIZE_SQL))
+      sessionConf.get(ENGINE_JDBC_SESSION_INITIALIZE_SQL))
     super.open()
     info(s"The jdbc session is started.")
   }

Reply via email to