dominikgehl commented on a change in pull request #33461:
URL: https://github.com/apache/spark/pull/33461#discussion_r678031516



##########
File path: python/pyspark/sql/catalog.py
##########
@@ -180,15 +180,38 @@ def tableExists(self, tableName, dbName=None):
 
         Examples
         --------
+
+        This function can check if a table is defined or not:
+
         >>> spark.catalog.tableExists("unexisting_table")
         False
         >>> df = spark.sql("CREATE TABLE tab1 (name STRING, age INT) USING 
parquet")
         >>> spark.catalog.tableExists("tab1")
         True
         >>> df = spark.sql("DROP TABLE tab1")
+        >>> spark.catalog.tableExists("unexisting_table")
+        False
+
+        It also works for views:
+
+        >>> spark.catalog.tableExists("view1")
+        False
+        >>> df = spark.sql("CREATE VIEW view1 AS SELECT 1")
+        >>> spark.catalog.tableExists("view1")
+        True
+        >>> df = spark.sql("DROP VIEW view1")
+        >>> spark.catalog.tableExists("view1")
+        False
+
+        And also for temporary views:
+
+        >>> df = spark.sql("CREATE TEMPORARY VIEW view1 AS SELECT 1")
+        >>> spark.catalog.tableExists("view1")
+        True
+        >>> df = spark.sql("DROP VIEW view1")
+        >>> spark.catalog.tableExists("view1")
+        False
         """
-        if dbName is None:
-            dbName = self.currentDatabase()

Review comment:
       replacing None with the current database caused the scala side to always 
return false




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to