Skip to content

Commit

Permalink
optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
aiceflower committed Jul 25, 2023
1 parent 5e584ab commit a134118
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,7 @@ object GovernanceCommonConf {
val SCALA_PARSE_APPEND_CODE_ENABLED =
CommonVars("linkis.scala.parse.append.code.enable", true).getValue

val SCALA_PARSE_APPEND_CODE =
CommonVars("linkis.scala.parse.append.code", "val linkisVar=1").getValue

}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ class ScalaCodeParser extends SingleCodeParser with Logging {
if (statementBuffer.nonEmpty) codeBuffer.append(statementBuffer.mkString("\n"))

// Append code `val linkisVar=1` in ends to prevent bugs that do not exit tasks for a long time
if (GovernanceCommonConf.SCALA_PARSE_APPEND_CODE_ENABLED) codeBuffer.append("val linkisVar=1")
if (GovernanceCommonConf.SCALA_PARSE_APPEND_CODE_ENABLED) {
codeBuffer.append(GovernanceCommonConf.SCALA_PARSE_APPEND_CODE)
}
codeBuffer.toArray
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ object SparkConfiguration extends Logging {

val LINKIS_SPARK_ETL_SUPPORT_HUDI = CommonVars[Boolean]("linkis.spark.etl.support.hudi", false)

val SCALA_PARSE_APPEND_CODE =
CommonVars("linkis.scala.parse.append.code", "val linkisVar=1").getValue

private def getMainJarName(): String = {
val somePath = ClassUtils.jarOfClass(classOf[SparkEngineConnFactory])
if (somePath.isDefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ class MDQPostExecutionHook extends SparkPostExecutionHook with Logging {
case l: CodeLanguageLabel => l.getCodeType
case _ => ""
}
val linkisVar = "val linkisVar=1"
if (
StringUtils.isEmpty(runType) || !SparkKind.FUNCTION_MDQ_TYPE.equalsIgnoreCase(
runType
) || (code != null && code.contains(linkisVar))
) || (code != null && code.contains(SparkConfiguration.SCALA_PARSE_APPEND_CODE))
) {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ class MDQPreExecutionHook extends SparkPreExecutionHook with Logging {
case _ =>
""
}
val linkisVar = "val linkisVar=1"
if (
StringUtils.isEmpty(runType) || !SparkKind.FUNCTION_MDQ_TYPE.equalsIgnoreCase(
runType
) || (code != null && code.contains(linkisVar))
) || (code != null && code.contains(SparkConfiguration.SCALA_PARSE_APPEND_CODE))
) {
return code
}
Expand Down

0 comments on commit a134118

Please sign in to comment.