Skip to content

Commit

Permalink
♻️ Refactor(FileDataSourceReader): Correct read function documentatio…
Browse files Browse the repository at this point in the history
…n and type in txt-ndjson enumeration
  • Loading branch information
camemre49 committed Sep 10, 2024
1 parent 2777ba4 commit 30828c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ class FileDataSourceReader(spark: SparkSession) extends BaseDataSourceReader[Fil
/**
* Read the source data
*
* @param mappingSourceBinding Configuration information for mapping source
* @param schema Optional schema for the source
* @param limit Limit the number of rows to read
* @param jobId The identifier of mapping job which executes the mapping
* @param mappingSourceBinding Configuration information for the mapping source
* @param mappingJobSourceSettings Common settings for the source system
* @param schema Optional schema for the source
* @param timeRange Time range for the data to read if given
* @param limit Limit the number of rows to read
* @param jobId The identifier of mapping job which executes the mapping
* @return
* @throws IllegalArgumentException If the path is not a directory for streaming jobs.
* @throws NotImplementedError If the specified source format is not implemented.
Expand Down Expand Up @@ -108,7 +110,7 @@ class FileDataSourceReader(spark: SparkSession) extends BaseDataSourceReader[Fil
.schema(csvSchema.orNull)
.csv(finalPath)
// assume that each line in the txt files contains a separate JSON object.
case SourceFileFormats.JSON | SourceFileFormats.TXT_NDJON=>
case SourceFileFormats.JSON | SourceFileFormats.TXT_NDJSON =>
if(mappingJobSourceSettings.asStream)
spark.readStream.options(mappingSourceBinding.options).schema(schema.orNull).json(finalPath)
// add a dummy column called 'filename' to print a log when the data reading is started for a file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ object SourceFileFormats {
final val PARQUET = "parquet"
final val JSON = "json"
final val AVRO = "avro"
final val TXT_NDJON = "txt-ndjson"
final val TXT_NDJSON = "txt-ndjson"
final val TXT_CSV = "txt-csv"
final val TXT = "txt"
}
Expand Down

0 comments on commit 30828c3

Please sign in to comment.