[ 
https://issues.apache.org/jira/browse/BEAM-13286?focusedWorklogId=683579&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-683579
 ]

ASF GitHub Bot logged work on BEAM-13286:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Nov/21 18:55
            Start Date: 18/Nov/21 18:55
    Worklog Time Spent: 10m 
      Work Description: TheNeuralBit commented on a change in pull request 
#16015:
URL: https://github.com/apache/beam/pull/16015#discussion_r752535700



##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJson.java
##########
@@ -527,7 +527,9 @@ private void writeValue(JsonGenerator gen, FieldType type, 
Object value) throws
           gen.writeNumber((BigDecimal) value);
           break;
         case DATETIME:
-          gen.writeString(((DateTime) value).toString()); // ISO 8601 format
+          assert (value instanceof ReadableInstant);

Review comment:
       I wasn't sure it was desirable to fail if value is not a ReadableInstant.
   
   Then again, I think your nudge has convinced me that is desirable, since we 
generally prefer failing rather than producing an incorrect result.




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 683579)
    Time Spent: 50m  (was: 40m)

> RowJson fails to serialize DATETIMEs produced by ZetaSQL
> --------------------------------------------------------
>
>                 Key: BEAM-13286
>                 URL: https://issues.apache.org/jira/browse/BEAM-13286
>             Project: Beam
>          Issue Type: Bug
>          Components: dsl-sql
>            Reporter: Brian Hulette
>            Assignee: Brian Hulette
>            Priority: P2
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> [ZetaSqlBeamTranslationUtils|https://github.com/apache/beam/blob/48984603fb74736be2887474b43990b150a87132/sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSqlBeamTranslationUtils.java#L254]
>  creates joda.time.Instant instances for DATETIME fields. While 
> [RowJson|https://github.com/apache/beam/blob/48984603fb74736be2887474b43990b150a87132/sdks/java/core/src/main/java/org/apache/beam/sdk/util/RowJson.java#L530]
>  explicitly casts to DateTime when deserializing. This causes a 
> ClassCastException for certain Beam SQL TableProviders (specifically any that 
> use JsonPayloadSerializerProvider).
> {code}
>               Caused by: java.lang.ClassCastException: org.joda.time.Instant 
> cannot be cast to org.joda.time.DateTime
>                       at 
> org.apache.beam.sdk.util.RowJson$RowJsonSerializer.writeValue(RowJson.java:530)
>                       at 
> org.apache.beam.sdk.util.RowJson$RowJsonSerializer.writeRow(RowJson.java:495)
>                       at 
> org.apache.beam.sdk.util.RowJson$RowJsonSerializer.serialize(RowJson.java:478)
>                       at 
> org.apache.beam.sdk.util.RowJson$RowJsonSerializer.serialize(RowJson.java:453)
>                       at 
> com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
>                       ... 37 more
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to