Skip to content

Commit b6e2cbf

Browse files
committed
fix: Map PdfBytes, ImageBytes, Uuid, TimeUuid and ZonedTimestamp to Spark types
from_feast_to_spark_type had no entries for PdfBytes, ImageBytes, Uuid, TimeUuid and ZonedTimestamp, so an on demand feature view declaring one of them failed in to_spark_df() before it ran. Map them to the Spark type of the Arrow values Feast produces for them: BinaryType, StringType and TimestampType. Signed-off-by: Denis Ivanov <go.denis.28@yandex.ru>
1 parent 3b5655a commit b6e2cbf

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

‎sdk/python/feast/infra/compute_engines/spark/nodes.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ def from_feast_to_spark_type(feast_type) -> Optional[SparkDataType]:
7575
if isinstance(feast_type, PrimitiveFeastType):
7676
mapping = {
7777
PrimitiveFeastType.BYTES: BinaryType(),
78+
PrimitiveFeastType.PDF_BYTES: BinaryType(),
79+
PrimitiveFeastType.IMAGE_BYTES: BinaryType(),
7880
PrimitiveFeastType.STRING: StringType(),
81+
PrimitiveFeastType.UUID: StringType(),
82+
PrimitiveFeastType.TIME_UUID: StringType(),
7983
PrimitiveFeastType.INT32: IntegerType(),
8084
PrimitiveFeastType.INT64: LongType(),
8185
PrimitiveFeastType.FLOAT64: DoubleType(),
8286
PrimitiveFeastType.FLOAT32: FloatType(),
8387
PrimitiveFeastType.BOOL: BooleanType(),
8488
PrimitiveFeastType.UNIX_TIMESTAMP: TimestampType(),
89+
PrimitiveFeastType.ZONED_TIMESTAMP: TimestampType(),
8590
PrimitiveFeastType.MAP: MapType(StringType(), StringType()),
8691
PrimitiveFeastType.JSON: StringType(),
8792
}

‎sdk/python/tests/unit/test_type_map.py‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,22 @@ def test_feast_string_to_spark_string(self):
13411341

13421342
assert from_feast_to_spark_type(String) == StringType()
13431343

1344+
def test_feast_uuid_to_spark_string(self):
1345+
from pyspark.sql.types import StringType
1346+
1347+
from feast.infra.compute_engines.spark.nodes import from_feast_to_spark_type
1348+
from feast.types import Uuid
1349+
1350+
assert from_feast_to_spark_type(Uuid) == StringType()
1351+
1352+
def test_feast_time_uuid_to_spark_string(self):
1353+
from pyspark.sql.types import StringType
1354+
1355+
from feast.infra.compute_engines.spark.nodes import from_feast_to_spark_type
1356+
from feast.types import TimeUuid
1357+
1358+
assert from_feast_to_spark_type(TimeUuid) == StringType()
1359+
13441360
def test_feast_int32_to_spark_integer(self):
13451361
from pyspark.sql.types import IntegerType
13461362

@@ -1389,6 +1405,22 @@ def test_feast_bytes_to_spark_binary(self):
13891405

13901406
assert from_feast_to_spark_type(Bytes) == BinaryType()
13911407

1408+
def test_feast_pdf_bytes_to_spark_binary(self):
1409+
from pyspark.sql.types import BinaryType
1410+
1411+
from feast.infra.compute_engines.spark.nodes import from_feast_to_spark_type
1412+
from feast.types import PdfBytes
1413+
1414+
assert from_feast_to_spark_type(PdfBytes) == BinaryType()
1415+
1416+
def test_feast_image_bytes_to_spark_binary(self):
1417+
from pyspark.sql.types import BinaryType
1418+
1419+
from feast.infra.compute_engines.spark.nodes import from_feast_to_spark_type
1420+
from feast.types import ImageBytes
1421+
1422+
assert from_feast_to_spark_type(ImageBytes) == BinaryType()
1423+
13921424
def test_feast_timestamp_to_spark_timestamp(self):
13931425
from pyspark.sql.types import TimestampType
13941426

@@ -1397,6 +1429,14 @@ def test_feast_timestamp_to_spark_timestamp(self):
13971429

13981430
assert from_feast_to_spark_type(UnixTimestamp) == TimestampType()
13991431

1432+
def test_feast_zoned_timestamp_to_spark_timestamp(self):
1433+
from pyspark.sql.types import TimestampType
1434+
1435+
from feast.infra.compute_engines.spark.nodes import from_feast_to_spark_type
1436+
from feast.types import ZonedTimestamp
1437+
1438+
assert from_feast_to_spark_type(ZonedTimestamp) == TimestampType()
1439+
14001440
def test_feast_map_to_spark_map(self):
14011441
from pyspark.sql.types import MapType, StringType
14021442

0 commit comments

Comments
 (0)