joellubi commented on code in PR #1456:
URL: https://github.com/apache/arrow-adbc/pull/1456#discussion_r1464167851


##########
go/adbc/driver/snowflake/record_reader.go:
##########
@@ -389,7 +386,15 @@ func jsonDataToArrow(ctx context.Context, bldr 
*array.RecordBuilder, ld gosnowfl
                                        return nil, err
                                }
 
-                               if tz != time.UTC {
+                               snowflakeType, ok := 
bldr.Schema().Field(i).Metadata.GetValue(MetadataKeySnowflakeType)
+                               if !ok {
+                                       return nil, errToAdbcErr(
+                                               adbc.StatusInvalidData,
+                                               fmt.Errorf("key %s not found in 
metadata for field %s", MetadataKeySnowflakeType, bldr.Schema().Field(i).Name),
+                                       )
+                               }

Review Comment:
   Ok I refactored this section. I kept the `SNOWFLAKE_TYPE` key check in place 
so that this can fail fast if someone changes the logic in the future. The part 
I changed was order of the checks for the timestamp variants.
   
   Previously it was `timestamp_ltz` -> `timestamp_ntz` -> fallthrough 
`timestamp_tz`.
   
   It turns out that `timestamp_ltz` and `timestamp_ntz` can be stored in the 
exact same way. Using `time.Unix(sec, nsec).In(tz)` was only changing the 
location metadata for the `time.Time` object. It doesn't have an effect on the 
output of `arrow.TimestampFromTime()` so for the nanosecond case they are 
equivalent.
   
   Now we check if it's a `timestamp_tz` first. If so, we perform the offset 
logic, etc.
   
   Otherwise we just extract and use the epoch nanoseconds directly, which 
applies to `timestamp_ltz`, `timestamp_ntz`, and the default case for unset 
type metadata.



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