CritasWang commented on code in PR #19150:
URL: https://github.com/apache/iotdb/pull/19150#discussion_r4546212105
##########
iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTree.java:
##########
@@ -131,18 +133,65 @@ protected void importSchemaFromCsvFile(File file) {
}
}
- private static CSVParser readCsvFile(String path) throws IOException {
- return CSVFormat.Builder.create(CSVFormat.DEFAULT)
- .setHeader()
- .setSkipHeaderRecord(true)
- .setQuote('`')
- .setEscape('\\')
- .setIgnoreEmptyLines(true)
- .build()
- .parse(new InputStreamReader(new FileInputStream(path)));
+ static CSVParser readCsvFile(String path) throws IOException {
+ CSVFormat.Builder builder =
+ CSVFormat.Builder.create(CSVFormat.DEFAULT)
+ .setHeader()
+ .setSkipHeaderRecord(true)
+ .setIgnoreEmptyLines(true);
+ if (isV2Format(readHeaderNames(path))) {
+ builder.setQuote('"');
+ } else {
+ builder.setQuote('`').setEscape('\\');
+ }
+ return builder.build().parse(new InputStreamReader(new
FileInputStream(path)));
Review Comment:
Fixed in 610e1a24eb — thanks, and you were right on all three points.\n\nAll
schema I/O is now pinned to (11 call sites):\n\n| File | Site |\n| --- | ---
|\n| | 3 × in (export, and the failed-records files) |\n| | parse stream,
and (header detection) |\n| | 3 × (table-model SQL output) |\n| | and the
failed-file |\n\nI also fixed the table-model sites in the same package: same
defect, and leaving them would have produced the same review comment on the
next PR.\n\nTwo regression tests in :\n- — writes through the real writer and
compares the bytes on disk against the expected UTF-8 encoding.\n- — writes
the file as UTF-8 bytes directly (so only the reader's charset can change the
outcome) and reads it back through and .\n\nBoth are charset-sensitive rather
than merely passing on a UTF-8 default: with the writer test fails before the
fix ( — the character is replaced) and passes after it. Full suite: 102 tests,
0 failures; test-compile green; clean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]