Skip to content
Merged
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
add partitions parameter
Signed-off-by: niklasvm <niklasvm@gmail.com>
  • Loading branch information
niklasvm committed Sep 7, 2022
commit 937a0e380a3e950c70c0d252c9819e645afc5d04
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class SparkMaterializationEngineConfig(FeastConfigBaseModel):
type: Literal["spark"] = "spark"
""" Type selector"""

partitions: int = None
"""Number of partitions to use when writing data to online store"""


@dataclass
class SparkMaterializationJob(MaterializationJob):
Expand Down Expand Up @@ -170,6 +173,11 @@ def _materialize_one(
)

spark_df = offline_job.to_spark_df()
if self.repo_config.batch_engine.partitions:
spark_df = spark_df.repartition(
self.repo_config.batch_engine.partitions
)

spark_df.foreachPartition(
lambda x: _process_by_partition(x, spark_serialized_artifacts)
)
Comment on lines +175 to +183
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_spark_materialization_consistency():
# "path": "data/online_store.db"
},
offline_store_creator=SparkDataSourceCreator,
batch_engine={"type": "spark"},
batch_engine={"type": "spark", "partitions": 100},
)
spark_environment = construct_test_environment(
spark_config, None, entity_key_serialization_version=1
Expand Down