Visitar URL original
fix: Spark Materialization Engine Cannot Infer Schema by jfw-ppi · Pull Request #5806 · feast-dev/feast · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: build Spark DataFrame from Arrow with schema and empty handling(#…
…5594)

Signed-off-by: Jacob Weinhold <29459386+jfw-ppi@users.noreply.github.com>
  • Loading branch information
jfw-ppi authored and ntkathole committed Jan 2, 2026
commit 611ead0e6f5d525f58a89fb5ab9c370c462ed8f8
12 changes: 10 additions & 2 deletions sdk/python/feast/infra/compute_engines/spark/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pandas as pd
from pyspark.sql import DataFrame, SparkSession, Window
from pyspark.sql import functions as F
from pyspark.sql.pandas.types import from_arrow_schema

from feast import BatchFeatureView, StreamFeatureView
from feast.aggregation import Aggregation
Expand Down Expand Up @@ -80,7 +81,15 @@ def execute(self, context: ExecutionContext) -> DAGValue:
if isinstance(retrieval_job, SparkRetrievalJob):
spark_df = cast(SparkRetrievalJob, retrieval_job).to_spark_df()
else:
spark_df = self.spark_session.createDataFrame(retrieval_job.to_arrow())
arrow_table = retrieval_job.to_arrow()
if arrow_table.num_rows == 0:
spark_schema = from_arrow_schema(arrow_table.schema)
spark_df = self.spark_session.createDataFrame(
self.spark_session.sparkContext.emptyRDD(), schema=spark_schema
)
else:
spark_df = self.spark_session.createDataFrame(arrow_table.to_pandas())


return DAGValue(
data=spark_df,
Expand All @@ -94,7 +103,6 @@ def execute(self, context: ExecutionContext) -> DAGValue:
},
)


class SparkAggregationNode(DAGNode):
def __init__(
self,
Expand Down