forked from byzer-org/byzer-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e1d439
commit f1d7fdd
Showing
11 changed files
with
41 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,31 +2,38 @@ package streaming.core.datasource.impl | |
|
||
import _root_.streaming.core.datasource._ | ||
import _root_.streaming.dsl.mmlib.algs.param.{BaseParams, WowParams} | ||
import _root_.streaming.dsl.{DslTool, ScriptSQLExec} | ||
import org.apache.spark.ml.param.Param | ||
import org.apache.spark.sql._ | ||
|
||
/** | ||
* 2019-02-19 WilliamZhu([email protected]) | ||
*/ | ||
class MLSQLExcel(override val uid: String) extends MLSQLSource with MLSQLSink with MLSQLSourceInfo with MLSQLRegistry with WowParams { | ||
class MLSQLExcel(override val uid: String) extends MLSQLSource with MLSQLSink with MLSQLSourceInfo with MLSQLRegistry with WowParams with DslTool { | ||
def this() = this(BaseParams.randomUID()) | ||
|
||
override def load(reader: DataFrameReader, config: DataSourceConfig): DataFrame = { | ||
val context = ScriptSQLExec.contextGetOrForTest() | ||
val format = config.config.getOrElse("implClass", fullFormat) | ||
reader.options(rewriteConfig(config.config)).format(format).load(config.config("_filePath_")) | ||
val owner = config.config.get("owner").getOrElse(context.owner) | ||
reader.options(rewriteConfig(config.config)).format(format).load(resourceRealPath(context.execListener, Option(owner), config.path)) | ||
} | ||
|
||
override def save(writer: DataFrameWriter[Row], config: DataSinkConfig): Unit = { | ||
val context = ScriptSQLExec.contextGetOrForTest() | ||
val format = config.config.getOrElse("implClass", fullFormat) | ||
|
||
writer.options(rewriteConfig(config.config)).format(format).save(config.config("_filePath_")) | ||
writer.options(rewriteConfig(config.config)).format(format).save(resourceRealPath(context.execListener, Option(context.owner), config.path)) | ||
} | ||
|
||
def rewriteConfig(config: Map[String, String]) = { | ||
config ++ Map("useHeader" -> config.getOrElse("useHeader", "false")) | ||
} | ||
|
||
override def sourceInfo(config: DataAuthConfig): SourceInfo = SourceInfo(shortFormat, "", "") | ||
override def sourceInfo(config: DataAuthConfig): SourceInfo = { | ||
val context = ScriptSQLExec.contextGetOrForTest() | ||
val owner = config.config.get("owner").getOrElse(context.owner) | ||
SourceInfo(shortFormat, "", resourceRealPath(context.execListener, Option(owner), config.path)) | ||
} | ||
|
||
override def explainParams(spark: SparkSession) = { | ||
_explainParams(spark) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters