Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the linkis task id to trino in the first line of tsql. #291

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

任务日志中需要打印 trino 集群地址 和queryId
engineExecutorContext.appendStdout

val trinoUser = Optional
.ofNullable(TRINO_DEFAULT_USER.getValue)
Expand Down