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

remove useless code and support more spark version #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -79,7 +79,7 @@ object Exchange {

val spark = session.getOrCreate()
// check the spark version
SparkValidate.validate(spark.version, "3.0.*", "3.1.*", "3.2.*", "3.3.*")
SparkValidate.validate(spark.version, "3.0.*", "3.1.*", "3.2.*", "3.3.*", "3.4.*", "3.5.*")
val startTime = System.currentTimeMillis()
var totalClientBatchSuccess: Long = 0L
var totalClientBatchFailure: Long = 0L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,30 +86,3 @@ class CSVReader(override val session: SparkSession, csvConfig: FileBaseSourceCon
.csv(path)
}
}

/**
* The CustomReader extend the FileBaseReader and support read text file from HDFS.
* Transformation is a function convert a line into Row.
* The structure of the row should be specified.
*
* @param session
* @param customConfig
* @param transformation
* @param structType
*/
abstract class CustomReader(override val session: SparkSession,
customConfig: FileBaseSourceConfigEntry,
transformation: String => Row,
filter: Row => Boolean,
structType: StructType)
extends FileBaseReader(session, customConfig.path) {

override def read(): DataFrame = {
val encoder = RowEncoder.apply(structType)
session.read
.text(path)
.filter(!_.getString(0).isEmpty)
.map(row => transformation(row.getString(0)))(encoder)
.filter(filter)
}
}
Loading