Skip to content

Commit

Permalink
Fix CSV File Scan Operator (#3217)
Browse files Browse the repository at this point in the history
Fix the issue #3055  that CSV Scan an empty file would result in error.

---------

Co-authored-by: Jiadong Bai <[email protected]>
  • Loading branch information
MiuMiuMiue and bobbai00 authored Jan 20, 2025
1 parent 58a214f commit 586496c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ class CSVScanSourceOpDesc extends ScanSourceOpDesc {
val attributeTypeList: Array[AttributeType] = inferSchemaFromRows(
data.iterator.asInstanceOf[Iterator[Array[Any]]]
)

val header: Array[String] =
if (hasHeader) parser.getContext.headers()
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) =>
Expand Down

0 comments on commit 586496c

Please sign in to comment.