Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-12885

Update Record Date and Time get Methods

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.0-M2
    • 2.0.0-M3
    • None
    • None

    Description

      I think I found a breaking bug from this commit https://github.com/apache/nifi/commit/250fe90b348fac515ea597c1985ca432ac7c3ac3#diff-ce496d3f0fc5a7e8a3c0431972f7069b4cf1af2e94f3a199f595ef195eb5ebfa

      The below passes in 1.20.0 but fails in 2.0

          @Test
          void testBasic() throws Exception {
              // setup
              final String schemaText = "{" +
                      "\"type\" : \"record\"," +
                      "\"name\" : \"TestRecord\"," +
                      "\"namespace\" : \"org.apache.nifi\"," +
                      "\"fields\" : [ {" +
                      "\"name\" : \"my_datestamp_field\"," +
                      "\"type\" : {" +
                      "\"type\" : \"long\"," +
                      "\"logicalType\" : \"timestamp-millis\"" +
                      "}" +
                      "} ]" +
                    "}";
              final RecordSchema schemaParsed = AvroTypeUtil.createSchema(new Schema.Parser().parse(schemaText));
      
              final HashMap<String, Object> item = new HashMap<>();
              item.put("my_datestamp_field", "2022-01-01 10:00:00.000");
      
              // act
              final MapRecord record = new MapRecord(schemaParsed, item);
              final Date myDateStampField = record.getAsDate("my_datestamp_field", "yyyy-MM-dd HH:mm:ss.SSS");
      
              // assert
      	// fails in 2.0; actual in 2.0.0-M2 is `1640995200000`
              assertEquals(1641031200000L, myDateStampField.getTime());
          }
      

      Attachments

        1. 1111.png
          81 kB
          crissaegrim

        Issue Links

          Activity

            People

              crissaegrim crissaegrim
              crissaegrim crissaegrim
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m