Skip to content

Commit

Permalink
[KYUUBI #6316] Support switching jdbc dialect based on session conf
Browse files Browse the repository at this point in the history
# 馃攳 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 馃敄

- [ ] 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 鈿帮笍

#### Behavior With This Pull Request 馃帀

#### 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

adac785 [senmiaoliu] support switch dialect of session

Authored-by: senmiaoliu <senmiaoliu@trip.com>
Signed-off-by: Shaoyun Chen <csy@apache.org>
  • Loading branch information
lsm1 authored and cxzl25 committed Apr 18, 2024
1 parent 8edcb00 commit 8b2bcfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.")
}
Expand Down

0 comments on commit 8b2bcfa

Please sign in to comment.