diff --git a/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/mdq/MDQPostExecutionHook.scala b/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/mdq/MDQPostExecutionHook.scala index 60c1dc1ef6..6aa3ac7c3f 100644 --- a/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/mdq/MDQPostExecutionHook.scala +++ b/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/mdq/MDQPostExecutionHook.scala @@ -56,7 +56,12 @@ class MDQPostExecutionHook extends SparkPostExecutionHook with Logging { case l: CodeLanguageLabel => l.getCodeType case _ => "" } - if (StringUtils.isEmpty(runType) || !SparkKind.FUNCTION_MDQ_TYPE.equalsIgnoreCase(runType)) { + val linkisVar = "val linkisVar=1" + if ( + StringUtils.isEmpty(runType) || !SparkKind.FUNCTION_MDQ_TYPE.equalsIgnoreCase( + runType + ) || (code != null && code.contains(linkisVar)) + ) { return } val sender = Sender.getSender(SparkConfiguration.MDQ_APPLICATION_NAME.getValue) diff --git a/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/mdq/MDQPreExecutionHook.scala b/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/mdq/MDQPreExecutionHook.scala index 836f748687..a9603cc736 100644 --- a/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/mdq/MDQPreExecutionHook.scala +++ b/linkis-engineconn-plugins/spark/src/main/scala/org/apache/linkis/engineplugin/spark/mdq/MDQPreExecutionHook.scala @@ -60,7 +60,12 @@ class MDQPreExecutionHook extends SparkPreExecutionHook with Logging { case _ => "" } - if (StringUtils.isEmpty(runType) || !SparkKind.FUNCTION_MDQ_TYPE.equalsIgnoreCase(runType)) { + val linkisVar = "val linkisVar=1" + if ( + StringUtils.isEmpty(runType) || !SparkKind.FUNCTION_MDQ_TYPE.equalsIgnoreCase( + runType + ) || (code != null && code.contains(linkisVar)) + ) { return code } val sender = Sender.getSender(SparkConfiguration.MDQ_APPLICATION_NAME.getValue)