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

    https://github.com/apache/spark/pull/22762#discussion_r226377181
  
    --- Diff: python/pyspark/sql/tests.py ---
    @@ -225,6 +225,63 @@ def sql_conf(self, pairs):
                     else:
                         self.spark.conf.set(key, old_value)
     
    +    @contextmanager
    +    def database(self, *databases):
    +        """
    +        A convenient context manager to test with some specific databases. 
This drops the given
    +        databases if exist and sets current database to "default" when it 
exits.
    +        """
    +        assert hasattr(self, "spark"), "it should have 'spark' attribute, 
having a spark session."
    +
    +        try:
    +            yield
    +        finally:
    +            for db in databases:
    +                self.spark.sql("DROP DATABASE IF EXISTS %s CASCADE" % db)
    +            self.spark.catalog.setCurrentDatabase("default")
    +
    +    @contextmanager
    +    def table(self, *tables):
    +        """
    +        A convenient context manager to test with some specific tables. 
This drops the given tables
    +        if exist when it exits.
    --- End diff --
    
    wait .. not a big deal but typo: `if exist when it exits.`.


---

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

Reply via email to