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

[GitHub] [spark] ueshin opened a new pull request, #40800: [SPARK-43146][CONNECT][PYTHON] Implement eager evaluation for __repr__ and _repr_html_

ueshin opened a new pull request, #40800:
URL: https://github.com/apache/spark/pull/40800

   ### What changes were proposed in this pull request?
   
   Implements eager evaluation for `DataFrame.__repr__` and `DataFrame._repr_html_`.
   
   ### Why are the changes needed?
   
   When `spark.sql.repl.eagerEval.enabled` is `True`, DataFrames should eagerly evaluate and show the results.
   
   ```py
   >>> spark.conf.set('spark.sql.repl.eagerEval.enabled', True)
   >>> spark.range(3)
   +---+
   | id|
   +---+
   |  0|
   |  1|
   |  2|
   +---+
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   The eager evaluation will be available.
   
   ### How was this patch tested?
   
   Enabled the related test.


-- 
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


[GitHub] [spark] ueshin commented on a diff in pull request #40800: [SPARK-43146][CONNECT][PYTHON] Implement eager evaluation for __repr__ and _repr_html_

Posted by "ueshin (via GitHub)" <gi...@apache.org>.
ueshin commented on code in PR #40800:
URL: https://github.com/apache/spark/pull/40800#discussion_r1168223649


##########
connector/connect/common/src/main/protobuf/spark/connect/relations.proto:
##########
@@ -456,6 +457,24 @@ message ShowString {
   bool vertical = 4;
 }
 
+// Try eager evaluation.
+// It will invoke 'Dataset.showString' or 'Dataset.htmlString' to compose the result.

Review Comment:
   Sure, we need another round-trip for retrieving some configs, though.
   As for `_repr_html_`, we need another protocol anyway because it uses some methods that is currently not provided in Spark Connect.



-- 
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


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #40800: [SPARK-43146][CONNECT][PYTHON] Implement eager evaluation for __repr__ and _repr_html_

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #40800:
URL: https://github.com/apache/spark/pull/40800#discussion_r1168241959


##########
connector/connect/common/src/main/protobuf/spark/connect/relations.proto:
##########
@@ -456,6 +457,24 @@ message ShowString {
   bool vertical = 4;
 }
 
+// Try eager evaluation.
+// It will invoke 'Dataset.showString' or 'Dataset.htmlString' to compose the result.

Review Comment:
   Yeah .. actually I think it needs a separate protobuf message for both ..



-- 
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


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #40800: [SPARK-43146][CONNECT][PYTHON] Implement eager evaluation for __repr__ and _repr_html_

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #40800:
URL: https://github.com/apache/spark/pull/40800#discussion_r1168241959


##########
connector/connect/common/src/main/protobuf/spark/connect/relations.proto:
##########
@@ -456,6 +457,24 @@ message ShowString {
   bool vertical = 4;
 }
 
+// Try eager evaluation.
+// It will invoke 'Dataset.showString' or 'Dataset.htmlString' to compose the result.

Review Comment:
   Yeah .. actually I think it needs a separate protobuf message at least for `_repr_html_`.



-- 
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


[GitHub] [spark] zhengruifeng commented on a diff in pull request #40800: [SPARK-43146][CONNECT][PYTHON] Implement eager evaluation for __repr__ and _repr_html_

Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #40800:
URL: https://github.com/apache/spark/pull/40800#discussion_r1168080225


##########
connector/connect/common/src/main/protobuf/spark/connect/relations.proto:
##########
@@ -456,6 +457,24 @@ message ShowString {
   bool vertical = 4;
 }
 
+// Try eager evaluation.
+// It will invoke 'Dataset.showString' or 'Dataset.htmlString' to compose the result.

Review Comment:
   I was wondering is it possible to implement the eager mode on client side only?



-- 
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


[GitHub] [spark] HyukjinKwon closed pull request #40800: [SPARK-43146][CONNECT][PYTHON] Implement eager evaluation for __repr__ and _repr_html_

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #40800: [SPARK-43146][CONNECT][PYTHON] Implement eager evaluation for __repr__ and _repr_html_
URL: https://github.com/apache/spark/pull/40800


-- 
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


[GitHub] [spark] ueshin commented on a diff in pull request #40800: [SPARK-43146][CONNECT][PYTHON] Implement eager evaluation for __repr__ and _repr_html_

Posted by "ueshin (via GitHub)" <gi...@apache.org>.
ueshin commented on code in PR #40800:
URL: https://github.com/apache/spark/pull/40800#discussion_r1168005573


##########
python/pyspark/sql/connect/plan.py:
##########
@@ -387,6 +387,30 @@ def plan(self, session: "SparkConnectClient") -> proto.Relation:
         return plan
 
 
+class EagerEvalString(LogicalPlan):
+    def __init__(self, child: Optional["LogicalPlan"], format: str) -> None:
+        super().__init__(child)
+        self._format = format
+
+    def plan(self, session: "SparkConnectClient") -> proto.Relation:
+        assert self._child is not None
+        plan = self._create_proto_relation()
+        plan.eager_eval_string.input.CopyFrom(self._child.plan(session))
+        if self._format == "show_string":
+            plan.eager_eval_string.format = proto.EagerEvalString.Format.FORMAT_SHOW_STRING
+        elif self._format == "html_string":
+            plan.eager_eval_string.format = proto.EagerEvalString.Format.FORMAT_HTML_STRING
+        else:
+            raise NotImplementedError(
+                """
+                Unsupported format: %s. Supported join types include:

Review Comment:
   Good catch. I forgot to update it.



-- 
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


[GitHub] [spark] jaceklaskowski commented on a diff in pull request #40800: [SPARK-43146][CONNECT][PYTHON] Implement eager evaluation for __repr__ and _repr_html_

Posted by "jaceklaskowski (via GitHub)" <gi...@apache.org>.
jaceklaskowski commented on code in PR #40800:
URL: https://github.com/apache/spark/pull/40800#discussion_r1167997673


##########
python/pyspark/sql/connect/plan.py:
##########
@@ -387,6 +387,30 @@ def plan(self, session: "SparkConnectClient") -> proto.Relation:
         return plan
 
 
+class EagerEvalString(LogicalPlan):
+    def __init__(self, child: Optional["LogicalPlan"], format: str) -> None:
+        super().__init__(child)
+        self._format = format
+
+    def plan(self, session: "SparkConnectClient") -> proto.Relation:
+        assert self._child is not None
+        plan = self._create_proto_relation()
+        plan.eager_eval_string.input.CopyFrom(self._child.plan(session))
+        if self._format == "show_string":
+            plan.eager_eval_string.format = proto.EagerEvalString.Format.FORMAT_SHOW_STRING
+        elif self._format == "html_string":
+            plan.eager_eval_string.format = proto.EagerEvalString.Format.FORMAT_HTML_STRING
+        else:
+            raise NotImplementedError(
+                """
+                Unsupported format: %s. Supported join types include:

Review Comment:
   "join types"? Is this to handle join queries?



-- 
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


[GitHub] [spark] HyukjinKwon commented on pull request #40800: [SPARK-43146][CONNECT][PYTHON] Implement eager evaluation for __repr__ and _repr_html_

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #40800:
URL: https://github.com/apache/spark/pull/40800#issuecomment-1514003542

   Merged to master.


-- 
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