You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zhengruifeng (via GitHub)" <gi...@apache.org> on 2023/03/14 01:28:38 UTC

[GitHub] [spark] zhengruifeng commented on a diff in pull request #40402: [SPARK-42020][CONNECT][PYTHON] Support UserDefinedType in Spark Connect

zhengruifeng commented on code in PR #40402:
URL: https://github.com/apache/spark/pull/40402#discussion_r1134776117


##########
connector/connect/common/src/main/protobuf/spark/connect/base.proto:
##########
@@ -272,6 +272,9 @@ message ExecutePlanResponse {
   // The metrics observed during the execution of the query plan.
   repeated ObservedMetrics observed_metrics = 6;
 
+  // The Spark schema
+  DataType schema = 7;

Review Comment:
   Is it a optional field only available in `df.collect`?



##########
python/pyspark/sql/connect/dataframe.py:
##########
@@ -1344,9 +1344,9 @@ def collect(self) -> List[Row]:
         if self._session is None:
             raise Exception("Cannot collect on empty session.")
         query = self._plan.to_proto(self._session.client)
-        table = self._session.client.to_table(query)
+        table, schema = self._session.client.to_table(query)
 
-        schema = from_arrow_schema(table.schema)
+        schema = schema or from_arrow_schema(table.schema)

Review Comment:
   when I was implementing the collection I was thinking about this dumb question: is it possible to make arrow schema 100% compatible with spark schema if we store the different fields in arrow metadata?
   e.g. for a spark `MapType`, store the `valueContainsNull` as a metadata in the `pa.schema`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org