-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reslve issue :datavane/tis#289 add reade header error message when en…
…count header with data formate
- Loading branch information
1 parent
1807a07
commit 026932d
Showing
3 changed files
with
32 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,10 @@ | |
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.TypeReference; | ||
import com.csvreader.CsvReader; | ||
import com.google.common.collect.Lists; | ||
import com.qlangtech.tis.extension.TISExtension; | ||
import com.qlangtech.tis.lang.TisException; | ||
import com.qlangtech.tis.plugin.ValidatorCommons; | ||
import com.qlangtech.tis.plugin.annotation.FormField; | ||
import com.qlangtech.tis.plugin.annotation.FormFieldType; | ||
import com.qlangtech.tis.plugin.datax.common.PluginFieldValidators; | ||
|
@@ -46,6 +49,7 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.regex.Matcher; | ||
|
||
/** | ||
* @author: 百岁([email protected]) | ||
|
@@ -142,6 +146,14 @@ protected void setCsvReaderConfig(CsvReader csvReader) { | |
Objects.requireNonNull(csvReader, "csvFormat.reader can not be null"); | ||
if (csvReader.readHeaders()) { | ||
this.fileHeader = csvReader.getHeaders();// new FileHeader(csvReader.getHeaderCount(), Lists.newArrayList()); | ||
List<String> headers = Lists.newArrayList(this.fileHeader); | ||
Matcher matcher = null; | ||
for (String colName : headers) { | ||
matcher = ValidatorCommons.PATTERN_DB_COL_NAME.matcher(colName); | ||
if (!matcher.matches()) { | ||
throw TisException.create("invalid file header:" + String.join(",", headers)); | ||
} | ||
} | ||
} else { | ||
throw new IllegalStateException("must contain head"); | ||
} | ||
|