From 5896ba7c6b388d783850e233b97ec1e23e9b48e8 Mon Sep 17 00:00:00 2001 From: WilliamZhu Date: Sun, 30 Oct 2022 11:13:00 +0800 Subject: [PATCH] issue-179 --- .../notebook/console/util/EngineExceptionUtils.java | 2 +- .../notebook/console/scalalib/hint/BaseHint.scala | 8 +++++--- .../notebook/console/scalalib/hint/PythonHint.scala | 12 +++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/kyligence/notebook/console/util/EngineExceptionUtils.java b/src/main/java/io/kyligence/notebook/console/util/EngineExceptionUtils.java index e0d6728..6e8278f 100644 --- a/src/main/java/io/kyligence/notebook/console/util/EngineExceptionUtils.java +++ b/src/main/java/io/kyligence/notebook/console/util/EngineExceptionUtils.java @@ -55,7 +55,7 @@ public static String parsePythonError(String stackTrace, Map c if (line.trim().startsWith("File")) { start = true; - result.add(pythonLinenoAlign(line.trim(), codeOffset)); + result.add(line.trim()); } else if (start) { result.add(line); diff --git a/src/main/scala/io/kyligence/notebook/console/scalalib/hint/BaseHint.scala b/src/main/scala/io/kyligence/notebook/console/scalalib/hint/BaseHint.scala index 3d632ff..7bf6469 100644 --- a/src/main/scala/io/kyligence/notebook/console/scalalib/hint/BaseHint.scala +++ b/src/main/scala/io/kyligence/notebook/console/scalalib/hint/BaseHint.scala @@ -15,9 +15,11 @@ trait BaseHint { item.stripMargin.stripPrefix("--%").stripPrefix("#%") } - val body = query.split("\n"). - filterNot(_.stripMargin.startsWith("--%")). - filterNot(_.stripMargin.startsWith("#%")).mkString("\n") + val body = query.split("\n").map { item => + if (item.stripMargin.startsWith("--%") || item.stripMargin.startsWith("#%")) { + "" + } else item + }.mkString("\n") var t: String = "mlsql" diff --git a/src/main/scala/io/kyligence/notebook/console/scalalib/hint/PythonHint.scala b/src/main/scala/io/kyligence/notebook/console/scalalib/hint/PythonHint.scala index 8f3d63d..91cbd1a 100644 --- a/src/main/scala/io/kyligence/notebook/console/scalalib/hint/PythonHint.scala +++ b/src/main/scala/io/kyligence/notebook/console/scalalib/hint/PythonHint.scala @@ -28,10 +28,10 @@ class PythonHint extends BaseHint { val confTableOpt = header.params.get("confTable").map(item => s""" confTable="${item}" and """).getOrElse("") val model = header.params.get("model").map(item => s""" model="${item}" and """).getOrElse("") - val schema = header.params.get("schema").map(item => s""" !python conf "schema=${item}"; """).getOrElse("") - val env = header.params.get("env").map(item => s""" !python env "PYTHON_ENV=${item}"; """).getOrElse("") - val dataMode = header.params.get("dataMode").map(item => s""" !python conf "dataMode=${item}"; """).getOrElse("") - val runIn = header.params.get("runIn").map(item => s""" !python conf "runIn=${item}"; """).getOrElse("") + val schema = header.params.get("schema").map(item => s""" !python conf '''schema=${item}'''; """).getOrElse("") + val env = header.params.get("env").map(item => s""" !python env '''PYTHON_ENV=${item}'''; """).getOrElse("") + val dataMode = header.params.get("dataMode").map(item => s""" !python conf '''dataMode=${item}'''; """).getOrElse("") + val runIn = header.params.get("runIn").map(item => s""" !python conf '''runIn=${item}'''; """).getOrElse("") s""" |${schema} @@ -43,9 +43,7 @@ class PythonHint extends BaseHint { |outputTable="${output}_0" and |${confTableOpt} |${model} - |code=''' - |${header.body} - |'''; + |code='''${header.body}'''; |${cacheStr} |""".stripMargin