This is an automated email from the ASF dual-hosted git repository.
gaogaotiantian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new c2130c9c7a7e [SPARK-60154][PYTHON][TEST] Add test for
Catalog.createDatabase with properties
c2130c9c7a7e is described below
commit c2130c9c7a7eeecc0aaece371d3085fde1437da3
Author: kjs1095 <[email protected]>
AuthorDate: Sun Oct 11 01:04:40 2026 -0700
[SPARK-60154][PYTHON][TEST] Add test for Catalog.createDatabase with
properties
### What changes were proposed in this pull request?
This ticket adds a test to `CatalogTestsMixin`
(python/pyspark/sql/tests/test_catalog.py).
The change introduces `A database creation with a comment and a property`,
and checks that both are applied.
- the comment via spark.catalog.getDatabase(db).description
- the custom property via DESCRIBE NAMESPACE EXTENDED
### Why are the changes needed?
Catalog.createDatabase(dbName, ifNotExists, properties) was introduced in
4.2.0 ([SPARK-56221](https://issues.apache.org/jira/browse/SPARK-56221)),
however no existing test covers properties . The current Python test, the
doctests, and the Scala tests all call createDatabase(dbName) only.
- the target code block this ticket targets
(`python/pyspark/sql/catalog.py`)
```python
def createDatabase(
self, dbName: str, ifNotExists: bool = False, properties:
Optional[Dict[str, str]] = None
) -> None:
# codes covered by existing test case
# uncovered part
if properties:
for k, v in properties.items():
m.put(k, v)
# rest of code
```
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
```bash
$ python/run-tests-with-coverage --python-executables=python3 \
--testnames pyspark.sql.tests.test_catalog
```
also pass
```bash
$ dev/lint-python
```
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code 2.1.296 (Claude Opus 5.5)
Closes #59357 from kjs1095/catalog-createdb-tests.
Authored-by: kjs1095 <[email protected]>
Signed-off-by: Tian Gao <[email protected]>
---
python/pyspark/sql/tests/test_catalog.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/python/pyspark/sql/tests/test_catalog.py
b/python/pyspark/sql/tests/test_catalog.py
index d813384a3a74..37cde48bac9a 100644
--- a/python/pyspark/sql/tests/test_catalog.py
+++ b/python/pyspark/sql/tests/test_catalog.py
@@ -527,6 +527,25 @@ class CatalogTestsMixin:
spark.catalog.dropDatabase(db, ifExists=False, cascade=True)
self.assertFalse(spark.catalog.databaseExists(db))
+ def test_catalog_create_database_with_properties(self):
+ spark = self.spark
+ db = "py_catalog_api_props_db"
+ with self.database(db):
+ spark.catalog.createDatabase(
+ db,
+ properties={
+ "comment": "py catalog api comment",
+ "py_catalog_api_k": "py_catalog_api_v",
+ },
+ )
+ self.assertEqual(spark.catalog.getDatabase(db).description, "py
catalog api comment")
+ info = {
+ r.info_name: r.info_value
+ for r in spark.sql(f"DESCRIBE NAMESPACE EXTENDED
{db}").collect()
+ }
+ self.assertIn("py_catalog_api_k", info["Properties"])
+ self.assertIn("py_catalog_api_v", info["Properties"])
+
def test_catalog_list_partitions(self):
spark = self.spark
t = "py_catalog_api_part_t"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]