Commit 91d62ce
committed
[SPARK-56221][SQL][PYTHON] Feature parity between spark.catalog.* vs DDL commands
### What changes were proposed in this pull request?
**SQL**
- `SHOW CACHED TABLES`: lists relations cached with an explicit name (`CACHE TABLE`, `catalog.cacheTable`, etc.); unnamed `Dataset.cache()` entries are not listed.
**`Catalog` API (Scala / Java / PySpark)**
- `listCachedTables()`: same information as `SHOW CACHED TABLES` (`CachedTable`: name, storage level).
- `dropTable` / `dropView`: drop persistent table or view (with `ifExists`, `purge` where applicable).
- `createDatabase` / `dropDatabase`: create or drop a namespace (with options: `ifNotExists` / `ifExists`, `cascade`, properties map).
- `listPartitions`: partition strings for a table (aligned with `SHOW PARTITIONS`).
- `listViews`: list views in the current or given namespace; optional name pattern.
- `getTableProperties`: all table properties (aligned with `SHOW TBLPROPERTIES`).
- `getCreateTableString`: DDL from `SHOW CREATE TABLE` (optional `asSerde`).
- `truncateTable`: remove all table data (not for views).
- `analyzeTable`: `ANALYZE TABLE ... COMPUTE STATISTICS` (optional `noScan`).
### Why are the changes needed?
Gives stable programmatic ways to do what users already do with SQL (SHOW CACHED TABLES, SHOW PARTITIONS, etc.), without routing everything through raw SQL.
### Does this PR introduce any user-facing change?
Yes. New SQL command, new Catalog API API.
### How was this patch tested?
Unittests were added.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #55025 from HyukjinKwon/SPARK-56221.
Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>1 parent 5d6eb71 commit 91d62ce
38 files changed
Lines changed: 2464 additions & 115 deletions
File tree
- common/utils/src/main/resources/error
- docs
- project
- python
- docs/source/reference/pyspark.sql
- pyspark
- sql
- connect
- proto
- tests
- testing
- sql
- api/src/main
- antlr4/org/apache/spark/sql/catalyst/parser
- scala/org/apache/spark/sql/catalog
- catalyst/src/main/scala/org/apache/spark/sql/catalyst
- parser
- plans/logical
- connect
- client
- jdbc/src/test/scala/org/apache/spark/sql/connect/client/jdbc
- jvm/src/test/scala/org/apache/spark/sql/connect
- common/src/main
- protobuf/spark/connect
- scala/org/apache/spark/sql/connect
- server/src/main/scala/org/apache/spark/sql/connect/planner
- core/src
- main/scala/org/apache/spark/sql
- classic
- execution
- command
- test
- resources/sql-tests/results
- nonansi
- scala/org/apache/spark/sql
- execution/command
- internal
- hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7463 | 7463 | | |
7464 | 7464 | | |
7465 | 7465 | | |
| 7466 | + | |
| 7467 | + | |
| 7468 | + | |
| 7469 | + | |
| 7470 | + | |
7466 | 7471 | | |
7467 | 7472 | | |
7468 | 7473 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| 443 | + | |
443 | 444 | | |
444 | 445 | | |
445 | 446 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| 37 | + | |
35 | 38 | | |
| 39 | + | |
36 | 40 | | |
| 41 | + | |
37 | 42 | | |
| 43 | + | |
38 | 44 | | |
39 | 45 | | |
40 | 46 | | |
| 47 | + | |
41 | 48 | | |
| 49 | + | |
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
| 54 | + | |
46 | 55 | | |
| 56 | + | |
47 | 57 | | |
48 | 58 | | |
49 | 59 | | |
50 | 60 | | |
51 | 61 | | |
52 | 62 | | |
53 | 63 | | |
| 64 | + | |
54 | 65 | | |
0 commit comments