Skip to content

Commit

Permalink
Remove logger calls
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonkmi committed Apr 5, 2024
1 parent bf3afb3 commit 8c46e22
Showing 1 changed file with 0 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
package org.codecraftlabs.spark.utils

import org.apache.log4j.Logger
import org.apache.spark.sql.SaveMode.Overwrite
import org.apache.spark.sql.functions.col
import org.apache.spark.sql.{DataFrame, SaveMode}

object DataFrameUtil {
@transient lazy val logger:Logger = Logger.getLogger(getClass.getName)
private val Header: String = "header"

def saveDataFrameToCsv(df: DataFrame,
partitions: Int = 1,
destination: String,
saveMode: SaveMode = Overwrite,
header: Boolean = true) : Unit = {
logger.debug(s"Saving data frame to csv with $partitions partitions, mode '${saveMode.name()}', destination '$destination'")
df.coalesce(partitions).write.mode(saveMode).option(Header, header).csv(destination)
}

def saveDataFrameToJson(df: DataFrame,
destination: String,
partitions: Int = 1,
saveMode: SaveMode = Overwrite): Unit = {
logger.debug(s"Saving data frame to json with $partitions partitions, mode '${saveMode.name()}', destination '$destination'")
df.coalesce(partitions).write.mode(saveMode).json(destination)
}

def saveDataFrameToParquet(df: DataFrame,
destination: String,
partitions: Int = 1,
saveMode: SaveMode = Overwrite): Unit = {
logger.debug(s"Saving data frame to parquet with $partitions partitions, mode '${saveMode.name()}', destination '$destination'")
df.coalesce(partitions).write.mode(saveMode).parquet(destination)
}

Expand Down

0 comments on commit 8c46e22

Please sign in to comment.