Github user xuanyuanking commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21370#discussion_r192349637
  
    --- Diff: python/pyspark/sql/dataframe.py ---
    @@ -351,8 +352,62 @@ def show(self, n=20, truncate=True, vertical=False):
             else:
                 print(self._jdf.showString(n, int(truncate), vertical))
     
    +    def _get_repl_config(self):
    +        """Return the configs for eager evaluation each time when __repr__ 
or
    +        _repr_html_ called by user or notebook.
    +        """
    +        eager_eval = self.sql_ctx.getConf(
    +            "spark.sql.repl.eagerEval.enabled", "false").lower() == "true"
    +        console_row = int(self.sql_ctx.getConf(
    +            "spark.sql.repl.eagerEval.maxNumRows", u"20"))
    +        console_truncate = int(self.sql_ctx.getConf(
    +            "spark.sql.repl.eagerEval.truncate", u"20"))
    +        return (eager_eval, console_row, console_truncate)
    +
         def __repr__(self):
    -        return "DataFrame[%s]" % (", ".join("%s: %s" % c for c in 
self.dtypes))
    +        (eager_eval, console_row, console_truncate) = 
self._get_repl_config()
    +        if not self._support_repr_html and eager_eval:
    --- End diff --
    
    Just want to avoid calling `_jdf` twice here, cause the second time called 
by `__repr__ ` is useless while `_repr_html_` is supported. The return string 
of `__repr__` will not finally be shown to notebook.


---

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

Reply via email to