Repository: feast-dev/feast

Issue:
Saved_dataset for spark offline store can be accessed only within the scope of the spark session, where it was created.
**Is your feature request related to a problem? Please describe.**
I would like to have a possibility to use the data of the registered saved_dataset in a different spark session. Now I have only a name in the feast registry without the data if I create a new spark session. 

Part of persist function:

```
"""
Run the retrieval and persist the results in the same offline store used for read.
Please note the persisting is done only within the scope of the spark session.
"""
assert isinstance(storage, SavedDatasetSparkStorage)
table_name = storage.spark_options.table
if not table_name:
    raise ValueError("Cannot persist, table_name is not defined")
self.to_spark_df().createOrReplaceTempView(table_name)
```


**Describe the solution you'd like**
Add possibility to save dataset as a table, for example when Spark Session config is included info about remote storage (hive, s3 path, etc)

**Describe alternatives you've considered**
Add an optional parameter for SparkOptions, which allows to save dataset as a table in any spark session configurations.

**Additional context**




Discussion:

Resolving patch:
diff --git a/sdk/python/feast/infra/offline_stores/contrib/spark_offline_store/spark.py b/sdk/python/feast/infra/offline_stores/contrib/spark_offline_store/spark.py
--- a/sdk/python/feast/infra/offline_stores/contrib/spark_offline_store/spark.py
+++ b/sdk/python/feast/infra/offline_stores/contrib/spark_offline_store/spark.py
@@ -352,13 +352,36 @@ def persist(
     ):
         """
         Run the retrieval and persist the results in the same offline store used for read.
-        Please note the persisting is done only within the scope of the spark session.
+        Please note the persisting is done only within the scope of the spark session for local warehouse directory.
         """
         assert isinstance(storage, SavedDatasetSparkStorage)
         table_name = storage.spark_options.table
         if not table_name:
             raise ValueError("Cannot persist, table_name is not defined")
-        self.to_spark_df().createOrReplaceTempView(table_name)
+        if self._has_remote_warehouse_in_config():
+            file_format = storage.spark_options.file_format
+            if not file_format:
+                self.to_spark_df().write.saveAsTable(table_name)
+            else:
+                self.to_spark_df().write.format(file_format).saveAsTable(table_name)
+        else:
+            self.to_spark_df().createOrReplaceTempView(table_name)
+
+    def _has_remote_warehouse_in_config(self) -> bool:
+        """
+        Check if Spark Session config has info about hive metastore uri
+        or warehouse directory is not a local path
+        """
+        self.spark_session.sparkContext.getConf().getAll()
+        try:
+            self.spark_session.conf.get("hive.metastore.uris")
+            return True
+        except Exception:
+            warehouse_dir = self.spark_session.conf.get("spark.sql.warehouse.dir")
+            if warehouse_dir and warehouse_dir.startswith("file:"):
+                return False
+            else:
+                return True
 
     def supports_remote_storage_export(self) -> bool:
         return self._config.offline_store.staging_location is not None


Test patch: