Skip to content

Commit

Permalink
Create sink only once (#528)
Browse files Browse the repository at this point in the history
* Create sink only once

* Create sources only once as well
  • Loading branch information
kevinwallimann authored Dec 18, 2024
1 parent fe94be8 commit ea21b3f
Showing 1 changed file with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,9 @@ class OperationSplitter(conf: Config,
sourceTables: Seq[SourceTable])(implicit spark: SparkSession): Seq[Job] = {
val specialCharacters = conf.getString(SPECIAL_CHARACTERS_IN_COLUMN_NAMES)
val temporaryDirectory = ConfigUtils.getOptionString(conf, TEMPORARY_DIRECTORY_KEY)
val sourceBase = SourceManager.getSourceByName(sourceName, conf, None)

sourceTables.map(sourceTable => {
val source = sourceTable.overrideConf match {
case Some(confOverride) => SourceManager.getSourceByName(sourceName, conf, Some(confOverride))
case None => sourceBase
}
val source = SourceManager.getSourceByName(sourceName, conf, sourceTable.overrideConf)

val disableCountQuery = ConfigUtils.getOptionBoolean(source.config, DISABLE_COUNT_QUERY).getOrElse(false)
val outputTable = metastore.getTableDef(sourceTable.metaTableName)
Expand All @@ -85,19 +81,10 @@ class OperationSplitter(conf: Config,
tables: Seq[TransferTable])(implicit spark: SparkSession): Seq[Job] = {
val specialCharacters = conf.getString(SPECIAL_CHARACTERS_IN_COLUMN_NAMES)
val temporaryDirectory = ConfigUtils.getOptionString(conf, TEMPORARY_DIRECTORY_KEY)
val sourceBase = SourceManager.getSourceByName(sourceName, conf, None)
val sinkBase = SinkManager.getSinkByName(sinkName, conf, None)

tables.map(transferTable => {
val source = transferTable.sourceOverrideConf match {
case Some(confOverride) => SourceManager.getSourceByName(sourceName, conf, Some(confOverride))
case None => sourceBase
}

val sink = transferTable.sinkOverrideConf match {
case Some(confOverride) => SinkManager.getSinkByName(sinkName, conf, Some(confOverride))
case None => sinkBase
}
val source = SourceManager.getSourceByName(sourceName, conf, transferTable.sourceOverrideConf)
val sink = SinkManager.getSinkByName(sinkName, conf, transferTable.sinkOverrideConf)

val disableCountQuery = ConfigUtils.getOptionBoolean(source.config, DISABLE_COUNT_QUERY).getOrElse(false)
val outputTable = TransferTableParser.getMetaTable(transferTable)
Expand Down Expand Up @@ -146,15 +133,10 @@ class OperationSplitter(conf: Config,
sinkName: String,
sinkTables: Seq[SinkTable])
(implicit spark: SparkSession): Seq[Job] = {
val sinkBase = SinkManager.getSinkByName(sinkName, conf, None)

sinkTables.map(sinkTable => {
val inputTable = metastore.getTableDef(sinkTable.metaTableName)

val sink = sinkTable.overrideConf match {
case Some(confOverride) => SinkManager.getSinkByName(sinkName, conf, Some(confOverride))
case None => sinkBase
}
val sink = SinkManager.getSinkByName(sinkName, conf, sinkTable.overrideConf)

val outputTableName = sinkTable.outputTableName.getOrElse(s"${sinkTable.metaTableName}->$sinkName")

Expand Down

0 comments on commit ea21b3f

Please sign in to comment.