Terry Kim created SPARK-30094:
---------------------------------

             Summary: Current namespace is not used during table resolution
                 Key: SPARK-30094
                 URL: https://issues.apache.org/jira/browse/SPARK-30094
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.0.0
            Reporter: Terry Kim


The following example shows the scenario where the current namespace is not 
respected:
{code:java}
sql("CREATE TEMPORARY VIEW t AS SELECT 2 AS i");
sql("CREATE TABLE testcat.t USING foo AS SELECT 1 AS id")
sql("USE testcat")
sql("SHOW CURRENT NAMESPACE").show
+-------+---------+
|catalog|namespace|
+-------+---------+
|testcat|         |
+-------+---------+

// `t` is resolved to `testcat.t`.
sql("DESCRIBE t").show
+---------------+---------+-------+
|       col_name|data_type|comment|
+---------------+---------+-------+
|             id|      int|       |
|               |         |       |
| # Partitioning|         |       |
|Not partitioned|         |       |
+---------------+---------+-------+

// Now create a table under `ns` namespace.
sql("CREATE TABLE testcat.ns.t USING foo AS SELECT 1 AS id")
sql("USE testcat.ns")
sql("SHOW CURRENT NAMESPACE").show
+-------+---------+
|catalog|namespace|
+-------+---------+
|testcat|       ns|
+-------+---------+

// `t` is not resolved any longer since the current namespace `ns` is not used.
sql("DESCRIBE t").show
org.apache.spark.sql.AnalysisException: Invalid command: 't' is a view not a 
table.; line 1 pos 0;
'DescribeTable 'UnresolvedV2Relation [t], 
org.apache.spark.sql.connector.InMemoryTableCatalog@2c5ead80, `t`, false

{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to