Skip to content

Commit

Permalink
condition added
Browse files Browse the repository at this point in the history
  • Loading branch information
MiuMiuMiue committed Jan 17, 2025
1 parent 8e8af8c commit 746388c
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,11 @@ class CSVScanSourceOpDesc extends ScanSourceOpDesc {
data.iterator.asInstanceOf[Iterator[Array[Any]]]
)

val header: Array[String] = Option(parser.getContext.headers())
.getOrElse((1 to attributeTypeList.length).map(i => s"column-$i").toArray)
// var header: Array[String] =
// if (hasHeader) parser.getContext.headers()
// else (1 to attributeTypeList.length).map(i => "column-" + i).toArray
//
// if (header == null) header = (1 to attributeTypeList.length).map(i => "column-" + i).toArray
val header: Array[String] =
if (hasHeader)
Option(parser.getContext.headers())
.getOrElse((1 to attributeTypeList.length).map(i => "column-" + i).toArray)
else (1 to attributeTypeList.length).map(i => "column-" + i).toArray

header.indices.foldLeft(Schema()) { (schema, i) =>
schema.add(header(i), attributeTypeList(i))
Expand Down

0 comments on commit 746388c

Please sign in to comment.