diff --git a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala index 5719e03eed2..674a67d0e38 100644 --- a/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala +++ b/externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/session/TrinoSessionImpl.scala @@ -54,12 +54,9 @@ class TrinoSessionImpl( override val handle: SessionHandle = conf.get(KYUUBI_SESSION_HANDLE_KEY).map(SessionHandle.fromUUID).getOrElse(SessionHandle()) - private val username: String = sessionConf + private val sessionUser: String = sessionConf .getOption(KyuubiReservedKeys.KYUUBI_SESSION_USER_KEY).getOrElse(currentUser) - private val trinoUser: String = sessionConf - .get(KyuubiConf.ENGINE_TRINO_CONNECTION_USER).getOrElse(username) - var trinoContext: TrinoContext = _ private var clientSession: ClientSession = _ private var catalogName: String = _ @@ -98,7 +95,7 @@ class TrinoSessionImpl( ClientSession.builder() .server(URI.create(connectionUrl)) - .principal(Optional.of(username)) + .principal(Optional.of(sessionUser)) .source("kyuubi") .catalog(catalogName) .schema(databaseName) @@ -136,7 +133,9 @@ class TrinoSessionImpl( require( serverScheme.equalsIgnoreCase("https"), "Trino engine using username/password requires HTTPS to be enabled") - builder.addInterceptor(OkHttpUtil.basicAuth(trinoUser, password)) + val user: String = sessionConf + .get(KyuubiConf.ENGINE_TRINO_CONNECTION_USER).getOrElse(sessionUser) + builder.addInterceptor(OkHttpUtil.basicAuth(user, password)) } builder.build()