Kamilkime opened a new pull request, #11283: URL: https://github.com/apache/nifi/pull/11283
<!-- Licensed to the Apache Software Foundation (ASF) under one or more --> <!-- contributor license agreements. See the NOTICE file distributed with --> <!-- this work for additional information regarding copyright ownership. --> <!-- The ASF licenses this file to You under the Apache License, Version 2.0 --> <!-- (the "License"); you may not use this file except in compliance with --> <!-- the License. You may obtain a copy of the License at --> <!-- http://www.apache.org/licenses/LICENSE-2.0 --> <!-- Unless required by applicable law or agreed to in writing, software --> <!-- distributed under the License is distributed on an "AS IS" BASIS, --> <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> <!-- See the License for the specific language governing permissions and --> <!-- limitations under the License. --> # Summary [NIFI-15973](https://issues.apache.org/jira/browse/NIFI-15973) Avoid Julian-calendar shift when converting `java.sql.Date` / `java.sql.Timestamp` values to `java.time` types (and back) in NiFi's record framework. `java.sql.Timestamp#toLocalDateTime`, `java.sql.Timestamp#valueOf(LocalDateTime)`, `java.sql.Date#toLocalDate`, and `java.sql.Date#valueOf(LocalDate)` all route through GregorianCalendar, which applies Julian-calendar semantics for years before 1582-10-15. As a result, a value whose epoch milliseconds represent year 0001 in the proleptic Gregorian calendar (the calendar `java.time`, Avro, BigQuery, or Snowflake all use) is rendered as year 0000 — about a 2-day backward shift. Downstream sinks that validate against an inclusive year-1-to-9999 range (e.g., the Snowflake Ingest SDK) then reject the row: `Timestamp out of representable inclusive range of years between 1 and 9999, ... value:0000-12-30T10:47Z`. The fix replaces every Julian-aware bridge between `java.sql.*` and `java.time.*` with an Instant-based one, which preserves the proleptic-Gregorian instant the source actually carried. **Tests:** - ObjectLocalDateFieldConverterTest (new): null input, LocalDate passthrough, java.sql.Date modern-year round-trip, and a year-0001 java.sql.Date regression test that asserts the result is year 0001 (not year 0000). - TestObjectLocalDateTimeFieldConverter: add testConvertTimestampYearOneIsProlepticGregorian (year-0001 Timestamp round-trip) and testConvertStringYearOneIsProlepticGregorian (year-0001 string parsed via formatter). - ObjectTimestampFieldConverterTest: add testConvertFieldStringYearOneIsProlepticGregorian and testConvertFieldLocalDateTimeYearOneIsProlepticGregorian to lock in the year-0001 result for both string and LocalDateTime inputs. - ObjectStringFieldConverterTest: add testConvertFieldTimestampYearOneIsProlepticGregorian covering the formatted-output path. - New regression tests fail on main and pass on this branch. **Compatibility:** Backwards compatible. Instant-based conversion and Julian-aware Timestamp / Date conversion agree for every date from 1582-10-15 onward, so all values produced after the Gregorian cutover (i.e., everything the vast majority of users have ever ingested) are unchanged. Pre-cutover values — including the 1582-10-05 → 1582-10-14 gap that Julian had but proleptic Gregorian does not — now match the proleptic-Gregorian instant the source actually carried, which is what `java.time`, Avro, and downstream sinks already assume. No public API signatures change, the fix is purely internal to the existing converter implementations. # Tracking Please complete the following tracking steps prior to pull request creation. ### Issue Tracking - [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created ### Pull Request Tracking - Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000` - Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000` - Pull request contains [commits signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) with a registered key indicating `Verified` status ### Pull Request Formatting - Pull Request based on current revision of the `main` branch - Pull Request refers to a feature branch with one commit containing changes # Verification Please indicate the verification steps performed prior to pull request creation. ### Build - [x] Build completed using `./mvnw clean install -P contrib-check` - [x] JDK 21 - [ ] JDK 25 ### Licensing - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html) - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files ### Documentation - [ ] Documentation formatting appears as expected in rendered files -- 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]
