mananmangal opened a new issue, #40860:
URL: https://github.com/apache/beam/issues/40860

   ### What happened?
   
   When a Beam `STRING` field is written to a `timestamp` or `timestamptz` 
column of an existing Iceberg table, IcebergIO only accepts a `T` between date 
and time. A string with a space, such as `2024-10-08 13:18:20.053+03:27`, fails 
with `DateTimeParseException`.
   
   RFC 3339 section 5.6 lets applications use a space instead of `T`. Python's 
`str(datetime)` produces this form, e.g. `2024-10-08 13:18:20.053000+00:00`.
   
   Beam version: master (`cba73417cd2`)
   
   Repro:
   
   ```java
   Schema beamSchema = Schema.builder().addStringField("ts").build();
   Row row = Row.withSchema(beamSchema).addValue("2024-10-08 
13:18:20.053+03:27").build();
   org.apache.iceberg.Schema icebergSchema =
       new org.apache.iceberg.Schema(
           Types.NestedField.required(1, "ts", Types.TimestampType.withZone()));
   
   IcebergUtils.beamRowToIcebergRecord(icebergSchema, row);
   ```
   
   ```
   java.time.format.DateTimeParseException: Text '2024-10-08 
13:18:20.053+03:27' could not be parsed at index 10
   ```
   
   `timestamp` fails the same way with `2024-10-08 13:18:20.053`.
   
   `IcebergUtils.getIcebergTimestampValue` parses with `OffsetDateTime.parse` 
and `LocalDateTime.parse`, which require `T`.
   
   Other parts of Beam already accept the space:
   - BigQueryIO: `DATETIME_SPACE_FORMATTER` in `BigQueryUtils`
   - `RowJson`: #38865
   - IcebergIO's own `FilterUtils`, for filter literals
   
   Proposed fix: on the write path, accept exactly one space in place of `T`. 
Strings with `T` keep parsing as they do today. A separator made of both a 
space and a `T` (the output behind #40110) stays rejected.
   
   Workaround: replace the space with `T` before writing.
   
   ### Issue Priority
   
   Priority: 3 (minor)
   
   ### Issue Components
   
   - [ ] Component: Python SDK
   - [x] Component: Java SDK
   - [ ] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [x] Component: IO connector
   - [ ] Component: Beam YAML
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Infrastructure
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Prism Runner
   - [ ] Component: Twister2 Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner
   


-- 
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]

Reply via email to