Skip to content

Commit

Permalink
Merge pull request #180 from byzer-org/issue-179
Browse files Browse the repository at this point in the history
#179  Python 执行报错后代码行数映射
  • Loading branch information
allwefantasy authored Oct 31, 2022
2 parents 292a0c3 + 5896ba7 commit 73e49b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static String parsePythonError(String stackTrace, Map<Integer, Integer> c

if (line.trim().startsWith("File")) {
start = true;
result.add(pythonLinenoAlign(line.trim(), codeOffset));
result.add(line.trim());

} else if (start) {
result.add(line);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -43,9 +43,7 @@ class PythonHint extends BaseHint {
|outputTable="${output}_0" and
|${confTableOpt}
|${model}
|code='''
|${header.body}
|''';
|code='''${header.body}''';
|${cacheStr}
|""".stripMargin

Expand Down

0 comments on commit 73e49b7

Please sign in to comment.