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

convert options in include statment to set statments #1633

Merged
merged 3 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
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 @@ -53,16 +53,28 @@ class ScriptIncludeSource extends IncludeSource with Logging {
case "byzer" | "byz" | "by" | "py" =>
newPathChunk = newPathChunk.dropRight(1)
suffix = pathChunk.last
case _ =>


}

newPathChunk.drop(1).foreach { item =>
rootPath.add(item)
}

val finalPath = rootPath.toPath + "." + suffix

Source.fromFile(finalPath).getLines().mkString("\n")
val action = options.getOrElse("__action__", "set")
val leftParams = options - "__action__"

val generateCode = action match {
case "set" => leftParams.map { item =>
s"""set ${item._1}='''${item._2}''';"""
}.mkString("\n")
case _ => ""
}

generateCode + Source.fromFile(finalPath).getLines().mkString("\n")
}

override def skipPathPrefix: Boolean = true
Expand Down
8 changes: 8 additions & 0 deletions streamingpro-it/src/test/resources/sql/simple/pr_1633.mlsql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--%comparator=tech.mlsql.it.IgnoreResultComparator

include lib.`gitee.com/allwefantasy/lib-core`
where alias="libCore";

include local.`libCore.udf.hello`;
select hello() as name as output;
!assert output ''' :name == "hello world" ''' "output should be 'hello world'";