Repository navigation
Conversation
JackieTien97
left a comment
There was a problem hiding this comment.
All 111 CLI tests passed. I verified the imported values against IoTDB Edge. The default millisecond export at +08:00 round-tripped, and an invalid field produced exit code 1 while preserving the other fields in its row.
I also confirmed a pre-existing exporter issue on the parent commit fba8ff7738. With -tz -05:00, the default CSV contains 2026-12-03T22:33:17-05:00.083. The fractional seconds follow the offset, so importing the generated file fails on the primary time column. Exporter formatting
| if (type != null) { | ||
| Object valueTrans = typeTrans(value, type); | ||
| Object valueTrans = | ||
| type == TSDataType.TIMESTAMP ? parseTimestampField(value) : typeTrans(value, type); |
There was a problem hiding this comment.
[P1] Honor the import time zone for fields without an offset. With the JVM in UTC and -tz +08:00, importing 1970-01-01T08:00:00 stored 28800000 ms and exited 0. The expected epoch value is 0. Table import reads -tz into timeZoneID, but this parser uses zoneId, which still holds the JVM default.
Region zones also need the offset for the date in the field. In a December run with America/New_York as the JVM zone, 2026-07-01T12:00:00 was stored as 17:00Z. The July offset puts it at 16:00Z. Please pass the configured ZoneId through to the parser and resolve offset-free values using the input date. Offset lookup
|
|
||
| private static Long parseTimestampField(String value) { | ||
| try { | ||
| return parseTimestamp(value); |
There was a problem hiding this comment.
[P2] Reject trailing characters after the UTC designator. Importing 2026-12-04T03:33:17.083Zjunk stored 1796355197083 and exited 0 without producing a failed-row file. The shared parser truncates the string at the first Z, so the exception handler never sees the malformed suffix. Please validate the entire field and cover this case with assertions for exit code 1 and the row in .failed_0. UTC normalization
| private static Long parseTimestampField(String value) { | ||
| try { | ||
| return parseTimestamp(value); | ||
| } catch (DateTimeException | ArithmeticException e) { |
There was a problem hiding this comment.
[P3] Preserve valid nanosecond timestamps near Long.MIN_VALUE. The default CSV export of -9223372036854775807 is 1677-09-21T00:12:43.145224193Z. Importing that CSV with -tp ns left the field NULL and exited 1. The numeric export of the same value round-tripped.
The nanosecond conversion multiplies the epoch second by one billion before adding the fractional part. The intermediate product overflows even though the final value fits in a long. Please use the negative-instant adjustment already present in the microsecond branch and cover this value in a round-trip test. Precision conversion
JackieTien97
left a comment
There was a problem hiding this comment.
A few additional points not covered by the earlier review. I re-ran DataToolRegressionTest on this head (47/47 pass) and confirmed both new tests fail when ImportDataTable.java is reverted to 7c6774e0fe.
| if (!failedRecords.isEmpty()) { | ||
| markFileFailed(); | ||
| writeFailedLinesFile(headerNames, failedFilePath, failedRecords); | ||
| return false; |
There was a problem hiding this comment.
[P2] Call out the wider exit-status change in the PR description. This return false applies to every failed record, not only TIMESTAMP fields. A CSV with abc in an INT32 column, or a column whose type cannot be inferred, used to print Import completely! and exit 0; it now exits 1. I think the new behavior is correct and matches ImportSchemaTable, but it is a user-visible change for scripts, so please state in the description that any partially failed table CSV now produces a nonzero exit status.
| type = headerTypeMap.get(headerName); | ||
| if (type != null) { | ||
| Object valueTrans = typeTrans(value, type); | ||
| Object valueTrans = |
There was a problem hiding this comment.
[P2] The tree-model importer has the same round-trip gap. ExportDataTree writes non-time columns with iterator.getString, which formats TIMESTAMP values through RpcUtils.formatDatetime (ISO offset format by default). ImportDataTree and AbstractDataTool.writeDataAlignedByDevice still send TIMESTAMP fields to typeTrans, i.e. Long.parseLong, and they also do not mark the file as failed when failedRecords is non-empty. Consider moving the TIMESTAMP handling into AbstractDataTool.typeTrans so both dialects share it and this call site needs no special case, or track the tree-model fix in a follow-up issue linked from this PR.
| long failures = loadFileFailedNum.sum(); | ||
| long successes = loadFileSuccessfulNum.sum(); | ||
| ImportDataScanTool.putToQueue(csv.toString()); | ||
| assertFalse(AbstractImportData.init(new ImportDataTable())); |
There was a problem hiding this comment.
[P3] Assert that the valid data is still written. The description says valid fields are kept when a field conversion fails, but this test only checks the counters and the failed-row file. Please capture session.insert (as in testTableCsvTimestampFieldRoundTrip) and assert that row 1,1000 was inserted, so a regression that drops the whole file would be caught.
| } | ||
|
|
||
| @Test | ||
| public void testTableCsvTimestampFieldRoundTrip() throws Exception { |
There was a problem hiding this comment.
[P3] Cover a non-millisecond precision. The fix relies on parseTimestamp applying timestampPrecision to formatted values, but the round trip only runs with ms. Besides the ns edge case raised earlier, please add a regular us round trip (export with timestampPrecision = "us", import the default-format CSV, and assert the original microsecond value).
When a directory import uses -fd, retain each source directory in the failure path so same-named CSV files can be retried independently. Keep the existing flat name for a single input file. Report invalid dates and odd-length hex fields as row failures while inserting valid fields and continuing the batch.
|
Please hold off on the review for a moment; I still have some issues to address. |
|
Thanks for the review, @JackieTien97. I added the round-trip test and opened #19537 for the tree model. Could you take another look when you have a chance? |
JackieTien97
left a comment
There was a problem hiding this comment.
Thanks for the updates. All earlier comments are addressed, and on d663b5bfe0 the 120 CLI tests, RpcUtilsTest, DateTimeUtilsTest, StatementGeneratorTest and the cast tests pass locally. Three things are still needed before this can be merged.
1. Move the server-side parser change to a separate PR. See the inline comment on DateTimeUtils. This PR should then contain only CLI changes and state that it depends on the new PR.
2. Update the PR description. It still lists only ImportDataTable and DataToolRegressionTest, but the branch now changes several user-visible behaviors. Per the repository's PR guidelines, please describe each one with a before/after example:
- Partially failed table CSV imports exit
1instead of0(already described). - With
-fdand a directory source, failed-row files keep the source's relative subdirectories instead of being written flat, where same-named files overwrote each other. - An invalid primary time, a record with too few columns, an invalid
DATE, or an odd-lengthBLOBnow sends only that row to the failed-row file. Previously the whole file was aborted. -tznow applies to offset-free values in table CSV imports. Previously they used the JVM default zone.export-dataoutput for negative offsets and second-precision historical offsets changes, for example from2026-12-03T22:33:17-05:00.083to2026-12-03T22:33:17.083-05:00. The sameRpcUtilspath also changesgetStringonTIMESTAMPcolumns in the Java Session, JDBC and CLI display, so please call that out as well.
3. Fix the -tf custom-format regression in RpcUtils. See the inline comment.
|
thank review~ |
Description
Closes #19532. Depends on #19540. Please merge the shared parser change first, then update this branch against
master.export-datawrites formattedTIMESTAMPfields by default. Table CSV import now uses the primary time column's timestamp parser for those fields. With an empty destination table containingevent_ts TIMESTAMP FIELDandv INT32 FIELD, importing a row withv=7gives the following results at millisecond precision.event_ts2026-12-04T11:33:17.083+08:00from default exportNULL,01796355197083,01796355197083from-tf timestamp1796355197083,01796355197083,0invalidNULL,0NULL,1Table CSV import
1. For example,abcin anINT32field previously produced exit code0. It now produces1, writes the valid fields and records the original row in.failed_0.-s source -fd failed, failed rows insource/a/data.csvandsource/b/data.csvpreviously went to the samefailed/data.csv.failed_0, so one file could overwrite the other. They now go tofailed/a/data.csv.failed_0andfailed/b/data.csv.failed_0.time,event_ts, an invalid primary time (bad,1000) or a short row (2) previously aborted the file. Now the importer skips that row, records it in.failed_0and continues to write later rows such as3,1000.DATE(2026-02-30) or odd-lengthBLOB(0xABC) previously aborted the file. Now the invalid field isNULL, other valid fields in that row are written, and the original row appears in.failed_0. Later valid rows are imported.-tzapplies to offset-free primary times andTIMESTAMPfields. With a UTC JVM and-tz +08:00, a primary time of1970-01-01T08:00:00previously became28800000ms. It now becomes0ms. An explicit offset in the CSV takes precedence.Timestamp output
Default and
iso8601formatting now put the fractional seconds before the complete offset. This affectsexport-data,getStringonTIMESTAMPcolumns in the Java Session and JDBC APIs, and CLI timestamp display.2026-12-04T03:33:17.083Z,-05:002026-12-03T22:33:17-05:00.0832026-12-03T22:33:17.083-05:001900-01-01T00:00:00.083Z,Europe/Paris1900-01-01T00:09:21+00.083:09:211900-01-01T00:09:21.083+00:09:21Custom export patterns retain their existing formatting. For example,
-tf yyyy-MM-dd-HH:mmformats1796355197083inAsia/Shanghaias2026-12-04-11:33.083.Regression coverage
DataToolRegressionTestcovers default-format CSV round trips at millisecond, microsecond and nanosecond precision, configured time zones, partial imports and failed-row paths.RpcUtilsTestcovers the shared timestamp formatter and the custom export pattern above. The original table CSV round trip was also tested against a local IoTDB Edge instance.Tested locally with the parser from #19540: all 120 CLI tests and all 10
RpcUtilsTestcases passed. With the currentmasterparser, four of the 120 CLI cases fail as expected: trailing text in either a primary time or aTIMESTAMPfield, a nanosecond value nearLong.MIN_VALUE, and a local time in a DST zone.The corresponding tree-model CSV import issue is tracked in #19537.