Skip to content

[SPARK-53840][SQL] Add AS JSON output support for SHOW TABLES and SHOW TABLE EXTENDED#56414

Closed
ayushbilala wants to merge 4 commits into
apache:masterfrom
ayushbilala:show-tables-json
Closed

[SPARK-53840][SQL] Add AS JSON output support for SHOW TABLES and SHOW TABLE EXTENDED#56414
ayushbilala wants to merge 4 commits into
apache:masterfrom
ayushbilala:show-tables-json

Conversation

@ayushbilala

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Support SHOW TABLES ... [AS JSON] and SHOW TABLE EXTENDED ... [AS JSON] to optionally display table listing metadata in JSON format.
SQL syntax:

SHOW TABLES [(IN|FROM) database_name] [[LIKE] pattern] [AS JSON]
SHOW TABLE EXTENDED [(IN|FROM) database_name] LIKE pattern [AS JSON]

Output: json_metadata: String

SHOW TABLES AS JSON:
{"tables":[{"name":"t1","namespace":["db"],"isTemporary":false}]}

SHOW TABLE EXTENDED ... AS JSON additionally includes catalog and type:
{"tables":[{"catalog":"spark_catalog","namespace":["db"],"name":"t1","type":"TABLE","isTemporary":false}]}

Why are the changes needed?

The existing text-based output of SHOW TABLES requires fragile string parsing for programmatic consumption.
A structured JSON format provides a stable, machine-readable contract for tooling and automation.

Does this PR introduce any user-facing change?

Yes. Two new SQL syntax variants that return JSON output. Existing commands without AS JSON are unaffected.
SHOW TABLE EXTENDED with both PARTITION and AS JSON is explicitly rejected.

How was this patch tested?

  • Parser tests in ShowTablesParserSuite for all AS JSON variants and the PARTITION + AS JSON error case.
  • Execution tests in ShowTablesSuiteBase covering JSON schema validation, empty databases, EXTENDED output, and temp view inclusion.
  • Manual verification in spark-shell

Was this patch authored or co-authored using generative AI tooling?

No


Continuation of #54824 (closed to move off fork master branch for CI)

@cloud-fan

Copy link
Copy Markdown
Contributor

failed tests unrelated, thanks, merging to master/4.x!

@cloud-fan cloud-fan closed this in 79dcac9 Jun 11, 2026
cloud-fan pushed a commit that referenced this pull request Jun 11, 2026
…W TABLE EXTENDED

### What changes were proposed in this pull request?
Support SHOW TABLES ... [AS JSON] and SHOW TABLE EXTENDED ... [AS JSON] to optionally display table listing metadata in JSON format.
SQL syntax:
```
SHOW TABLES [(IN|FROM) database_name] [[LIKE] pattern] [AS JSON]
SHOW TABLE EXTENDED [(IN|FROM) database_name] LIKE pattern [AS JSON]
```
Output: json_metadata: String

SHOW TABLES AS JSON:
`{"tables":[{"name":"t1","namespace":["db"],"isTemporary":false}]}`

SHOW TABLE EXTENDED ... AS JSON additionally includes catalog and type:
`{"tables":[{"catalog":"spark_catalog","namespace":["db"],"name":"t1","type":"TABLE","isTemporary":false}]}`

### Why are the changes needed?
The existing text-based output of SHOW TABLES requires fragile string parsing for programmatic consumption.
A structured JSON format provides a stable, machine-readable contract for tooling and automation.

### Does this PR introduce _any_ user-facing change?
Yes. Two new SQL syntax variants that return JSON output. Existing commands without AS JSON are unaffected.
SHOW TABLE EXTENDED with both PARTITION and AS JSON is explicitly rejected.

### How was this patch tested?
- Parser tests in `ShowTablesParserSuite` for all AS JSON variants and the PARTITION + AS JSON error case.
- Execution tests in `ShowTablesSuiteBase` covering JSON schema validation, empty databases, EXTENDED output, and temp view inclusion.
- Manual verification in spark-shell

### Was this patch authored or co-authored using generative AI tooling?
No

---
Continuation of #[54824](#54824) (closed to move off fork `master` branch for CI)

Closes #56414 from ayushbilala/show-tables-json.

Authored-by: Ayush <bilalaayush@hotmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit 79dcac9)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants