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

   ### What changes were proposed in this pull request?
   
   Corresponding changes in the python side of 
[SPARK-39236](https://issues.apache.org/jira/browse/SPARK-39236) (Make 
CreateTable API and ListTables API compatible )
   
   ### Why are the changes needed?
   
   to support 3-layer-namespace in the python side
   
   ### Does this PR introduce _any_ user-facing change?
   
   yes
   
   
   ### How was this patch tested?
   1, for existing UT, update them to cover original cases;
   
   2, for 3-layer-namespace, maually test:
     - 2.1 move all `InMemoryCatalog` related files from `test` to `main`, by 
`mv 
sql/catalyst/src/test/scala/org/apache/spark/sql/connector/catalog/InMemory*.scala
 sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/`
    - 2.2 fix a few conflicts
    - 2.3 compile and then maually test in the pyspark repl, for example:
   
   ```python
   
   spark.sql("CREATE DATABASE my_db")
   spark.createDataFrame([(1, 1)]).createOrReplaceTempView("temp_tab")
   spark.sql("CREATE TABLE tab1 (name STRING, age INT) USING parquet")
   spark.sql("CREATE TABLE my_db.tab2 (name STRING, age INT) USING parquet")
   
   schema = StructType([StructField("a", IntegerType(), True)])
   description = "this is a test table"
   
   spark.conf.set("spark.sql.catalog.testcat", 
"org.apache.spark.sql.connector.catalog.InMemoryCatalog")
   
   spark.catalog.createTable("testcat.my_db.my_table", source="json", 
schema=schema, description=description)
   
   
   In [2]: spark.catalog.listTables()
   Out[2]: 
   [Table(name='tab1', catalog='spark_catalog', namespace=['default'], 
description=None, tableType='MANAGED', isTemporary=False),
    Table(name='temp_tab', catalog='spark_catalog', namespace=None, 
description=None, tableType='TEMPORARY', isTemporary=True)]
   
   In [3]: spark.catalog.listTables("my_db")
   Out[3]: 
   [Table(name='tab2', catalog='spark_catalog', namespace=['my_db'], 
description=None, tableType='MANAGED', isTemporary=False),
    Table(name='temp_tab', catalog='spark_catalog', namespace=None, 
description=None, tableType='TEMPORARY', isTemporary=True)]
   
   In [4]: spark.catalog.listTables("testcat.my_db")
   Out[4]: [Table(name='my_table', catalog='testcat', namespace=['my_db'], 
description='this is a test table', tableType='MANAGED', isTemporary=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