Skip to content

Commit 9bfcc41

Browse files
zhey16bobbai00
authored andcommitted
Fix CSV File Scan Operator (#3217)
Fix the issue #3055 that CSV Scan an empty file would result in error. --------- Co-authored-by: Jiadong Bai <[email protected]>
1 parent 4faa78c commit 9bfcc41

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/workflow-operator/src/main/scala/edu/uci/ics/amber/operator/source/scan/csv/CSVScanSourceOpDesc.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ class CSVScanSourceOpDesc extends ScanSourceOpDesc {
9090
val attributeTypeList: Array[AttributeType] = inferSchemaFromRows(
9191
data.iterator.asInstanceOf[Iterator[Array[Any]]]
9292
)
93+
9394
val header: Array[String] =
94-
if (hasHeader) parser.getContext.headers()
95+
if (hasHeader)
96+
Option(parser.getContext.headers())
97+
.getOrElse((1 to attributeTypeList.length).map(i => "column-" + i).toArray)
9598
else (1 to attributeTypeList.length).map(i => "column-" + i).toArray
9699

97100
header.indices.foldLeft(Schema()) { (schema, i) =>

0 commit comments

Comments
 (0)