Skip to content

Commit f29cb8c

Browse files
authored
Update type conversion from pandas to timestamp to support various the timestamp types (feast-dev#1603)
* Fix precommit to run black on commit Signed-off-by: Achal Shah <achals@gmail.com> * Update type conversion from pandas to timestamp to support various the specifications Signed-off-by: Achal Shah <achals@gmail.com> * Undo precommit changs Signed-off-by: Achal Shah <achals@gmail.com> * make format Signed-off-by: Achal Shah <achals@gmail.com>
1 parent a2581c5 commit f29cb8c

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

sdk/python/feast/data_source.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,7 @@ def __init__(
598598
self._file_options = FileOptions(file_format=file_format, file_url=file_url)
599599

600600
super().__init__(
601-
event_timestamp_column
602-
or self._infer_event_timestamp_column(r"timestamp\[\w\w\]"),
601+
event_timestamp_column or self._infer_event_timestamp_column(r"^timestamp"),
603602
created_timestamp_column,
604603
field_mapping,
605604
date_partition_column,
@@ -744,7 +743,6 @@ def get_table_column_names_and_types(self) -> Iterable[Tuple[str, str]]:
744743
from google.cloud import bigquery
745744

746745
client = bigquery.Client()
747-
bq_columns_query = ""
748746
name_type_pairs = []
749747
if self.table_ref is not None:
750748
project_id, dataset_id, table_id = self.table_ref.split(".")

sdk/python/feast/type_map.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import re
1516
from datetime import datetime, timezone
1617
from typing import Any, Dict, List, Union
1718

@@ -438,8 +439,14 @@ def pa_to_value_type(pa_type: object):
438439

439440

440441
def pa_to_feast_value_type(value: Union[pa.lib.ChunkedArray, str]) -> ValueType:
442+
value_type = (
443+
value.type.__str__() if isinstance(value, pa.lib.ChunkedArray) else value
444+
)
445+
446+
if re.match(r"^timestamp", value_type):
447+
return ValueType.INT64
448+
441449
type_map = {
442-
"timestamp[ms]": ValueType.INT64,
443450
"int32": ValueType.INT32,
444451
"int64": ValueType.INT64,
445452
"double": ValueType.DOUBLE,
@@ -455,9 +462,7 @@ def pa_to_feast_value_type(value: Union[pa.lib.ChunkedArray, str]) -> ValueType:
455462
"list<item: binary>": ValueType.BYTES_LIST,
456463
"list<item: bool>": ValueType.BOOL_LIST,
457464
}
458-
return type_map[
459-
value.type.__str__() if isinstance(value, pa.lib.ChunkedArray) else value
460-
]
465+
return type_map[value_type]
461466

462467

463468
def pa_column_to_timestamp_proto_column(column: pa.lib.ChunkedArray) -> List[Timestamp]:

0 commit comments

Comments
 (0)