Skip to content

Commit

Permalink
SNOW-911238: after CR 4
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dstempniak committed Oct 5, 2023
1 parent 96dbab6 commit 3657f94
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ func arrowSnowflakeTimestampToTime(
fraction := extractFraction(value, scale)
ret = time.Unix(epoch, fraction).UTC()
}
return &ret
case timestampLtzType:
if column.DataType().ID() == arrow.STRUCT {
structData := column.(*array.Struct)
Expand All @@ -400,26 +399,24 @@ func arrowSnowflakeTimestampToTime(
fraction := extractFraction(value, scale)
ret = time.Unix(epoch, fraction).In(loc)
}
return &ret
case timestampTzType:
structData := column.(*array.Struct)
if structData.NumField() == 2 {
value := structData.Field(0).(*array.Int64).Int64Values()
timezone := structData.Field(1).(*array.Int32).Int32Values()
epoch := extractEpoch(value[recIdx], scale)
fraction := extractFraction(value[recIdx], scale)
loc := Location(int(timezone[recIdx]) - 1440)
ret = time.Unix(epoch, fraction).In(loc)
locTz := Location(int(timezone[recIdx]) - 1440)
ret = time.Unix(epoch, fraction).In(locTz)
} else {
epoch := structData.Field(0).(*array.Int64).Int64Values()
fraction := structData.Field(1).(*array.Int32).Int32Values()
timezone := structData.Field(2).(*array.Int32).Int32Values()
loc := Location(int(timezone[recIdx]) - 1440)
ret = time.Unix(epoch[recIdx], int64(fraction[recIdx])).In(loc)
locTz := Location(int(timezone[recIdx]) - 1440)
ret = time.Unix(epoch[recIdx], int64(fraction[recIdx])).In(locTz)
}
return &ret
}
return nil
return &ret
}

func extractEpoch(value int64, scale int) int64 {
Expand Down

0 comments on commit 3657f94

Please sign in to comment.