Skip to content

Commit

Permalink
Add the linkis task id to trino in the first line of tsql.
Browse files Browse the repository at this point in the history
  • Loading branch information
HmhWz authored and casionone committed Oct 7, 2023
1 parent 42f5837 commit 5950d61
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import scala.collection.JavaConverters._
import com.google.common.cache.{Cache, CacheBuilder}
import io.trino.client._
import okhttp3.OkHttpClient
import org.apache.linkis.governance.common.utils.JobUtils

class TrinoEngineConnExecutor(override val outputPrintLimit: Int, val id: Int)
extends ConcurrentComputationExecutor(outputPrintLimit) {
Expand Down Expand Up @@ -151,7 +152,7 @@ class TrinoEngineConnExecutor(override val outputPrintLimit: Int, val id: Int)
code: String
): ExecuteResponse = {
val enableSqlHook = TRINO_SQL_HOOK_ENABLED.getValue
val realCode = if (StringUtils.isBlank(code)) {
var realCode = if (StringUtils.isBlank(code)) {
"SELECT 1"
} else if (enableSqlHook) {
TrinoSQLHook.preExecuteHook(code.trim)
Expand All @@ -161,7 +162,9 @@ class TrinoEngineConnExecutor(override val outputPrintLimit: Int, val id: Int)

TrinoCode.checkCode(realCode)
logger.info(s"trino client begins to run psql code:\n $realCode")

val jobId = JobUtils.getJobIdFromMap(engineExecutorContext.getProperties)
// 在第一行加taskid,trino接收后做定制化处理
realCode = s"--linkis_task_id=$jobId" + "\n" + realCode
val currentUser = getCurrentUser(engineExecutorContext.getLabels)
val trinoUser = Optional
.ofNullable(TRINO_DEFAULT_USER.getValue)
Expand Down

0 comments on commit 5950d61

Please sign in to comment.