Skip to content

Commit 3ec943a

Browse files
pyalexkevjumba
authored andcommitted
fix: Feature with timestamp type is incorrectly interpreted by Go FS (#2588)
Signed-off-by: pyalex <[email protected]>
1 parent a846530 commit 3ec943a

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

go/types/typeconversion.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ func ProtoTypeToArrowType(sample *types.Value) (arrow.DataType, error) {
4040
case *types.Value_DoubleListVal:
4141
return arrow.ListOf(arrow.PrimitiveTypes.Float64), nil
4242
case *types.Value_UnixTimestampVal:
43-
return arrow.FixedWidthTypes.Time64ns, nil
43+
return arrow.FixedWidthTypes.Time32s, nil
4444
case *types.Value_UnixTimestampListVal:
45-
return arrow.ListOf(arrow.FixedWidthTypes.Time64ns), nil
45+
return arrow.ListOf(arrow.FixedWidthTypes.Time32s), nil
4646
default:
4747
return nil,
4848
fmt.Errorf("unsupported proto type in proto to arrow conversion: %s", sample.Val)
@@ -80,9 +80,9 @@ func ValueTypeEnumToArrowType(t types.ValueType_Enum) (arrow.DataType, error) {
8080
case types.ValueType_DOUBLE_LIST:
8181
return arrow.ListOf(arrow.PrimitiveTypes.Float64), nil
8282
case types.ValueType_UNIX_TIMESTAMP:
83-
return arrow.FixedWidthTypes.Time64ns, nil
83+
return arrow.FixedWidthTypes.Time32s, nil
8484
case types.ValueType_UNIX_TIMESTAMP_LIST:
85-
return arrow.ListOf(arrow.FixedWidthTypes.Time64ns), nil
85+
return arrow.ListOf(arrow.FixedWidthTypes.Time32s), nil
8686
default:
8787
return nil,
8888
fmt.Errorf("unsupported value type enum in enum to arrow type conversion: %s", t)
@@ -119,9 +119,9 @@ func copyProtoValuesToArrowArray(builder array.Builder, values []*types.Value) e
119119
for _, v := range values {
120120
fieldBuilder.Append(v.GetDoubleVal())
121121
}
122-
case *array.Time64Builder:
122+
case *array.Time32Builder:
123123
for _, v := range values {
124-
fieldBuilder.Append(arrow.Time64(v.GetUnixTimestampVal()))
124+
fieldBuilder.Append(arrow.Time32(v.GetUnixTimestampVal()))
125125
}
126126
case *array.ListBuilder:
127127
for _, list := range values {
@@ -157,9 +157,9 @@ func copyProtoValuesToArrowArray(builder array.Builder, values []*types.Value) e
157157
for _, v := range list.GetDoubleListVal().GetVal() {
158158
valueBuilder.Append(v)
159159
}
160-
case *array.Time64Builder:
160+
case *array.Time32Builder:
161161
for _, v := range list.GetUnixTimestampListVal().GetVal() {
162-
valueBuilder.Append(arrow.Time64(v))
162+
valueBuilder.Append(arrow.Time32(v))
163163
}
164164
}
165165
}
@@ -227,10 +227,10 @@ func ArrowValuesToProtoValues(arr arrow.Array) ([]*types.Value, error) {
227227
}
228228
values = append(values,
229229
&types.Value{Val: &types.Value_BoolListVal{BoolListVal: &types.BoolList{Val: vals}}})
230-
case arrow.FixedWidthTypes.Time64ns:
230+
case arrow.FixedWidthTypes.Time32s:
231231
vals := make([]int64, int(offsets[idx])-pos)
232232
for j := pos; j < int(offsets[idx]); j++ {
233-
vals[j-pos] = int64(listValues.(*array.Time64).Value(j))
233+
vals[j-pos] = int64(listValues.(*array.Time32).Value(j))
234234
}
235235

236236
values = append(values,
@@ -278,11 +278,11 @@ func ArrowValuesToProtoValues(arr arrow.Array) ([]*types.Value, error) {
278278
values = append(values,
279279
&types.Value{Val: &types.Value_StringVal{StringVal: arr.(*array.String).Value(idx)}})
280280
}
281-
case arrow.FixedWidthTypes.Time64ns:
281+
case arrow.FixedWidthTypes.Time32s:
282282
for idx := 0; idx < arr.Len(); idx++ {
283283
values = append(values,
284284
&types.Value{Val: &types.Value_UnixTimestampVal{
285-
UnixTimestampVal: int64(arr.(*array.Time64).Value(idx))}})
285+
UnixTimestampVal: int64(arr.(*array.Time32).Value(idx))}})
286286
}
287287
default:
288288
return nil, fmt.Errorf("unsupported arrow to proto conversion for type %s", arr.DataType())

sdk/python/feast/embedded_go/online_features_service.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
pa.bool_(): "bool_val",
3232
pa.string(): "string_val",
3333
pa.binary(): "bytes_val",
34-
pa.time64("ns"): "unix_timestamp_val",
34+
pa.time32("s"): "unix_timestamp_val",
3535
}
3636

3737
ARROW_LIST_TYPE_TO_PROTO_FIELD = {
@@ -42,7 +42,7 @@
4242
pa.bool_(): "bool_list_val",
4343
pa.string(): "string_list_val",
4444
pa.binary(): "bytes_list_val",
45-
pa.time64("ns"): "unix_timestamp_list_val",
45+
pa.time32("s"): "unix_timestamp_list_val",
4646
}
4747

4848
ARROW_LIST_TYPE_TO_PROTO_LIST_CLASS = {
@@ -53,7 +53,7 @@
5353
pa.bool_(): Value_pb2.BoolList,
5454
pa.string(): Value_pb2.StringList,
5555
pa.binary(): Value_pb2.BytesList,
56-
pa.time64("ns"): Value_pb2.Int64List,
56+
pa.time32("s"): Value_pb2.Int64List,
5757
}
5858

5959
# used for entity types only
@@ -270,8 +270,8 @@ def record_batch_to_online_response(record_batch):
270270
proto_field_name = ARROW_LIST_TYPE_TO_PROTO_FIELD[field.type.value_type]
271271

272272
column = record_batch.columns[idx]
273-
if field.type.value_type == pa.time64("ns"):
274-
column = column.cast(pa.list_(pa.int64()))
273+
if field.type.value_type == pa.time32("s"):
274+
column = column.cast(pa.list_(pa.int32()))
275275

276276
for v in column.tolist():
277277
feature_vector.values.append(
@@ -281,8 +281,8 @@ def record_batch_to_online_response(record_batch):
281281
proto_field_name = ARROW_TYPE_TO_PROTO_FIELD[field.type]
282282

283283
column = record_batch.columns[idx]
284-
if field.type == pa.time64("ns"):
285-
column = column.cast(pa.int64())
284+
if field.type == pa.time32("s"):
285+
column = column.cast(pa.int32())
286286

287287
for v in column.tolist():
288288
feature_vector.values.append(

0 commit comments

Comments
 (0)